您的位置:寻梦网首页编程乐园Java天地JSP 专辑JSP001 HTML 离线版
Java 天地
JSP001 HTML 离线版
FAQ汇萃 >> SQL之家 >> 用SQL如何建立表?

由 amtd 发布于: 2001-02-14 09:55

Post

CREATE TABLE statement
Creates a new table.

CREATE TABLE [<database>.[<owner>].]<table_name>

{<col_name> <column_properties> [<constraint> [<constraint>
[... <constraint>]]]
| [[,] <constraint>]}
[[,] {<next_col_name> |
<next_constraint>}...]

[ON <segment_name>]

<column_properties> =
<datatype> [NULL | NOT NULL | IDENTITY[(<seed>, <increment>)]]
<constraint> =
For a PRIMARY KEY constraint:
[CONSTRAINT <constraint_name>]
PRIMARY KEY [CLUSTERED | NONCLUSTERED]
(<col_name> [, <col_name2> [..., <col_name16>]])
[ON <segment_name>]
For a UNIQUE constraint:
[CONSTRAINT <constraint_name>]
UNIQUE [CLUSTERED | NONCLUSTERED]
(<col_name> [, <col_name2> [..., <col_name16>]])
[ON <segment_name>]
For a FOREIGN KEY constraint:
[CONSTRAINT <constraint_name>]
[FOREIGN KEY (<col_name> [, <col_name2>
[..., <col_name16> ]])]
REFERENCES [<owner>.]<ref_table> [(<ref_col>
[, <ref_col2> [..., <ref_col16>]])]
For a DEFAULT constraint:
[CONSTRAINT <constraint_name>]
DEFAULT {<constant_expression> | <niladic-function> | NULL}
[FOR <col_name>]
For a CHECK constraint(s):
[CONSTRAINT <constraint_name>]
CHECK [NOT FOR REPLICATION] (<expression>)



__________________



资料来源: JSP001.com