爱心技术专栏专题

CREATETABLE–SQLCommand

摘录:MSSQL Server教程 来源:MSSQL Server教程 加入时间:2007年03月25日
摘要:
CREATETABLE–SQLCommand

sql>CREATE TABLE – SQL Command


转载:转载请保留本信息,本文来自
http://www.51dibs.com
/html/2006/article/info22/a_93b64b04ebe74cd2.htm

CREATETABLE–SQLCommand

站点:爱心种子小博士 关键字:CREATETABLE–SQLComma

   
CREATETABLE–SQLCommand

sql>CREATE TABLE – SQL Command

Creates a table having the specified fields.

CREATE TABLE | DBF TableName1 [NAME LongTableName] [FREE]   (FieldName1 FieldType [(nFieldWidth [, nPrecision])]      [NULL | NOT NULL]       [CHECK lExpression1 [ERROR cMessageText1]]      [DEFAULT eExpression1]      [PRIMARY KEY | UNIQUE]      [REFERENCES TableName2 [TAG TagName1]]      [NOCPTRANS]   [, FieldName2 ...]      [, PRIMARY KEY eExpression2 TAG TagName2      |, UNIQUE eExpression3 TAG TagName3]      [, FOREIGN KEY eExpression4 TAG TagName4 [NODUP]         REFERENCES TableName3 [TAG TagName5]]      [, CHECK lExpression2 [ERROR cMessageText2]])| FROM ARRAY ArrayName

Parameters

TableName1
Specifies the name of the table to create. The TABLE and DBF options are identical.
NAME LongTableName
Specifies a long name for the table. A long table name can be specified only when a database is open because long table names are stored in databases.

Long names can contain up to 128 characters and can be used in place of short file names in the database.

FREE
Specifies that the table will not be added to an open database. FREE isnt required if a database isnt open.
(FieldName1 FieldType [(nFieldWidth [, nPrecision])]
Specifies the field name, field type, field width, and field precision (number of decimal places), respectively.

A single table can contain up to 255 fields. If one or more fields allow null values, the limit is reduced by one to 254 fields.

FieldType is a single letter indicating the fields data type. Some field data types require that you specify nFieldWidth or nPrecision, or both.

The following table lists the values for FieldType and whether nFieldWidth and nPrecision are required.

FieldTypenFieldWidth nPrecisionDescription
C