数据库 创建表的命令是什么?

数据库 创建表的命令是什么?,第1张

CREATE TABLE

[ database_name.[ owner ] .| owner.] table_name

( { <column_definition >

| column_name AS computed_column_expression

| <table_constraint >::= [ CONSTRAINT constraint_name ] }

| [ { PRIMARY KEY | UNIQUE } [ ,...n ]

)

[ ON { filegroup | DEFAULT } ]

[ TEXTIMAGE_ON { filegroup | DEFAULT } ]

<column_definition >::= { column_name data_type }

[ COLLATE <collation_name >]

[ [ DEFAULT constant_expression ]

| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]

]

[ ROWGUIDCOL]

[ <column_constraint >] [ ...n ]

<column_constraint >::= [ CONSTRAINT constraint_name ]

{ [ NULL | NOT NULL ]

| [ { PRIMARY KEY | UNIQUE }

[ CLUSTERED | NONCLUSTERED ]

[ WITH FILLFACTOR = fillfactor ]

[ON {filegroup | DEFAULT} ] ]

]

| [ [ FOREIGN KEY ]

REFERENCES ref_table [ ( ref_column ) ]

[ ON DELETE { CASCADE | NO ACTION } ]

[ ON UPDATE { CASCADE | NO ACTION } ]

[ NOT FOR REPLICATION ]

]

| CHECK [ NOT FOR REPLICATION ]

( logical_expression )

}

<table_constraint >::= [ CONSTRAINT constraint_name ]

{ [ { PRIMARY KEY | UNIQUE }

[ CLUSTERED | NONCLUSTERED ]

{ ( column [ ASC | DESC ] [ ,...n ] ) }

[ WITH FILLFACTOR = fillfactor ]

[ ON { filegroup | DEFAULT } ]

]

| FOREIGN KEY

[ ( column [ ,...n ] ) ]

REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]

[ ON DELETE { CASCADE | NO ACTION } ]

[ ON UPDATE { CASCADE | NO ACTION } ]

[ NOT FOR REPLICATION ]

| CHECK [ NOT FOR REPLICATION ]

( search_conditions )

}

CREATETABLE。在CREATETABLE之后给出,必须符合标识符命名规则。表名称被指定为db_name.tbl_name,以便在特定的数据库中创建表。无论是否有当前数据库,都可以通过这种方式创建。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10074919.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存