Section courante

A propos

Section administrative du site

CREATE TYPE

Crée le type
  Microsoft SQL Server

Syntaxe

CREATE TYPE [ schema_name. ] type_name
{
[
FROM base_type
[ ( precision [ , scale ] ) ]
[ NULL | NOT NULL ]
]
| EXTERNAL NAME assembly_name [ .class_name ]
| AS TABLE ( { column_definition | computed_column_definition [ ,... n ] }
[ table_constraint ] [ ,... n ]
[ table_index ] [ ,... n ] } )

} [ ; ]

column_definition ::=
column_name data_type
[ COLLATE collation_name ]
[ NULL | NOT NULL ]
[
DEFAULT constant_expression ]
| [ IDENTITY [ ( seed ,increment ) ]
]
[ ROWGUIDCOL ] [ column_constraint [ ...n ] ]

data type ::=
[ type_schema_name . ] type_name
[ ( precision [ , scale ] | max |
[ { CONTENT | DOCUMENT } ] xml_schema_collection ) ]

column_constraint ::=
{ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
[
WITH ( index_option [ ,...n ] )
]
| CHECK ( logical_expression )
}

computed_column_definition ::=

column_name AS computed_column_expression
[ PERSISTED [ NOT NULL ] ]
[
{ PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
[
WITH ( index_option [ ,...n ] )
]
| CHECK ( logical_expression )
]

table_constraint ::=
{
{ PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
( column [ ASC | DESC ] [ ,...n ] )
[
WITH ( index_option [ ,...n ] )
]
| CHECK ( logical_expression )
}

index_option ::=
{
IGNORE_DUP_KEY = { ON | OFF }
}

table_index ::=
INDEX constraint_name
[ CLUSTERED | NONCLUSTERED ] (column [ ASC | DESC ] [ ,... n ] )} }
Syntaxe du type de données défini par l'utilisateur
CREATE TYPE [schema_name. ] type_name
AS TABLE ( { column_definition [ ,... n ] }
| [ table_constraint ] [ ,... n ]
| [ table_index ] [ ,... n ] } )
[ WITH ( table_option [ ,... n ] ) ]
[ ; ]

column_definition ::=
column_name data_type
[ COLLATE collation_name ] [ NULL | NOT NULL ] [
[ IDENTITY [ (1 , 1) ]
]
[ column_constraint [ ... n ] ] [ column_index ]

data type ::=
[type_schema_name . ] type_name [ (precision [ , scale ]) ]

column_constraint ::=
{ PRIMARY KEY { NONCLUSTERED HASH WITH (BUCKET_COUNT = bucket_count)
| NONCLUSTERED } }

table_constraint ::=
{ PRIMARY KEY { NONCLUSTERED HASH (column [ ,... n ] )
WITH (BUCKET_COUNT = bucket_count)
| NONCLUSTERED (column [ ASC | DESC ] [ ,... n ] ) } }

column_index ::=
INDEX index_name
{ { [ NONCLUSTERED ] HASH WITH (BUCKET_COUNT = bucket_count)
| NONCLUSTERED } }

table_index ::=
INDEX constraint_name
{ { [ NONCLUSTERED ] HASH (column [ ,... n ] ) WITH (BUCKET_COUNT = bucket_count)
| [NONCLUSTERED] (column [ ASC | DESC ] [ ,... n ] )} }

table_option ::=
{
[MEMORY_OPTIMIZED = {ON | OFF}]
}
Syntaxe des types de table optimisés en mémoire définie par l'utilisateur

Description

Cette instruction permet de créer un type d'alias de données ou un type utilisateur dans la base de données courante de SQL Server.



Dernière mise à jour : Vendredi, le 19 Juin 2020