SQL Server--怎样用ADO在SQL SERVER中建库,建表

2018-09-06 12:41

阅读:438

  通过ADO可以访问SQLSERVER,并执行相应的SQL语句建库、建表,下面是SQLSERVERBOOKSONLINE中的相关定义。

建表:

CREATETABLE
[
database_name.[owner].
owner.
]table_name
(
{
column_nameAScomputed_column_expression

}[,...n]
)
[ON{filegroupDEFAULT}]
[TEXTIMAGE_ON{filegroupDEFAULT}]



::={column_namedata_type}
[[DEFAULTconstant_expression]
[IDENTITY[(seed,increment)[NOTFORREPLICATION]]]
]
[ROWGUIDCOL]
[][...n]

::=[CONSTRAINTconstraint_name]
{
[NULLNOTNULL]
[{PRIMARYKEYUNIQUE}
[CLUSTEREDNONCLUSTERED]
[WITHFILLFACTOR=fillfactor]
[ON{filegroupDEFAULT}}
]
[[FOREIGNKEY]
REFERENCESref_table[(ref_column)]
[NOTFORREPLICATION]
]
CHECK[NOTFORREPLICATION]
(logical_expression)
}

::=[CONSTRAINTconstraint_name]
{
[{PRIMARYKEYUNIQUE}
[CLUSTEREDNONCLUSTERED]
{(column[,...n])}
[WITHFILLFACTOR=fillfactor]
[ON{filegroupDEFAULT}]
]
FOREIGNKEY
[(column[,...n])]
REFERENCESref_table[(ref_column[,...n])]
[NOTFORREPLICATION]
CHECK[NOTFORREPLICATION]
(search_conditions)
}



建库:

CREATEDATABASEdatabase_name
[ON[PRIMARY]
[[,...n]]
[,[,...n]]
]
[LOGON{[,...n]}]
[FORLOADFORATTACH]

::=

([NAME=logical_file_name,]
FILENAME=os_file_name
[,SIZE=size]
[,MAXSIZE={max_sizeUNLIMITED}]
[,FILEGROWTH=growth_increment])[,...n]

::=

FILEGROUPfilegroup_name[,...n]


评论


亲,登录后才可以留言!