如何使用SQL语句创建表,要完整的语句。

 我来答
海凌霜明宇
2019-11-01 · TA获得超过3万个赞
知道小有建树答主
回答量:1.1万
采纳率:30%
帮助的人:596万
展开全部
自己打开企业管理器,随便找个表,导出一个创建表的脚本,就什么都有了。
要语法,SQL的联机帮助里就有:
CREATE
TABLE
[
database_name
.
[
schema_name
]
.
|
schema_name
.
]
table_name
(
{
|
}
[
]
[
,...n
]
)
[
ON
{
partition_scheme_name
(
partition_column_name
)
|
filegroup
|
"default"
}
]
[
{
TEXTIMAGE_ON
{
filegroup
|
"default"
}
]
[
;
]
::=
column_name
[
COLLATE
collation_name
]
[
NULL
|
NOT
NULL
]
[
[
CONSTRAINT
constraint_name
]
DEFAULT
constant_expression
]
|
[
IDENTITY
[
(
seed
,increment
)
]
[
NOT
FOR
REPLICATION
]
]
[
ROWGUIDCOL
]
[
[
...n
]
]
::=
[
type_schema_name
.
]
type_name
[
(
precision
[
,
scale
]
|
max
|
[
{
CONTENT
|
DOCUMENT
}
]
xml_schema_collection
)
]
::=
[
CONSTRAINT
constraint_name
]
{
{
PRIMARY
KEY
|
UNIQUE
}
[
CLUSTERED
|
NONCLUSTERED
]
[
WITH
FILLFACTOR
=
fillfactor
|
WITH
(
<
index_option
>
[
,
...n
]
)
]
[
ON
{
partition_scheme_name
(
partition_column_name
)
|
filegroup
|
"default"
}
]
|
[
FOREIGN
KEY
]
REFERENCES
[
schema_name
.
]
referenced_table_name
[
(
ref_column
)
]
[
ON
DELETE
{
NO
ACTION
|
CASCADE
|
SET
NULL
|
SET
DEFAULT
}
]
[
ON
UPDATE
{
NO
ACTION
|
CASCADE
|
SET
NULL
|
SET
DEFAULT
}
]
[
NOT
FOR
REPLICATION
]
|
CHECK
[
NOT
FOR
REPLICATION
]
(
logical_expression
)
}
::=
column_name
AS
computed_column_expression
[
PERSISTED
[
NOT
NULL
]
]
[
[
CONSTRAINT
constraint_name
]
{
PRIMARY
KEY
|
UNIQUE
}
[
CLUSTERED
|
NONCLUSTERED
]
[
WITH
FILLFACTOR
=
fillfactor
|
WITH
(
[
,
...n
]
)
]
|
[
FOREIGN
KEY
]
REFERENCES
referenced_table_name
[
(
ref_column
)
]
[
ON
DELETE
{
NO
ACTION
|
CASCADE
}
]
[
ON
UPDATE
{
NO
ACTION
}
]
[
NOT
FOR
REPLICATION
]
|
CHECK
[
NOT
FOR
REPLICATION
]
(
logical_expression
)
[
ON
{
partition_scheme_name
(
partition_column_name
)
|
filegroup
|
"default"
}
]
]
<
table_constraint
>
::=
[
CONSTRAINT
constraint_name
]
{
{
PRIMARY
KEY
|
UNIQUE
}
[
CLUSTERED
|
NONCLUSTERED
]
(column
[
ASC
|
DESC
]
[
,...n
]
)
[
WITH
FILLFACTOR
=
fillfactor
|WITH
(
[
,
...n
]
)
]
[
ON
{
partition_scheme_name
(partition_column_name)
|
filegroup
|
"default"
}
]
|
FOREIGN
KEY
(
column
[
,...n
]
)
REFERENCES
referenced_table_name
[
(
ref_column
[
,...n
]
)
]
[
ON
DELETE
{
NO
ACTION
|
CASCADE
|
SET
NULL
|
SET
DEFAULT
}
]
[
ON
UPDATE
{
NO
ACTION
|
CASCADE
|
SET
NULL
|
SET
DEFAULT
}
]
[
NOT
FOR
REPLICATION
]
|
CHECK
[
NOT
FOR
REPLICATION
]
(
logical_expression
)
}
::=
{
PAD_INDEX
=
{
ON
|
OFF
}
|
FILLFACTOR
=
fillfactor
|
IGNORE_DUP_KEY
=
{
ON
|
OFF
}
|
STATISTICS_NORECOMPUTE
=
{
ON
|
OFF
}
|
ALLOW_ROW_LOCKS
=
{
ON
|
OFF}
|
ALLOW_PAGE_LOCKS
={
ON
|
OFF}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式