sqlserver2005用语句创建表

2024-12-19 01:31:47
推荐回答(5个)
回答1:

新建查询,然后输入如下sql语句:

create table 表名(列名1 类型 [not null] [primary key],列名2 类型 [not null],..)

以上是模板,列属性根据具体要做的表来一一设置,建完后刷新一下数据库

回答2:

在本教程中创建表之前,请执行 USE 命令将数据库上下文更改为 TestData 数据库。否则,您将在以前连接到的数据库中创建表。那可能是默认数据库。除非已经更改默认数据库,否则默认数据库是 master 数据库。不应该在 master 数据库中创建对象。

1.将查询编辑器连接切换到 TestData 数据库
在查询编辑器窗口中,键入以下代码,并执行它以更改与 TestData 数据库的连接。

USE TestData
GO

2.创建表
CREATE TABLE dbo.Products
(ProductID int PRIMARY KEY NOT NULL,
ProductName varchar(25) NOT NULL,
Price money NULL,
ProductDescription text NULL)
GO

回答3:

点击菜单栏上的“新建查询”按钮,然后在弹出的输入区域输入
USE jxcbook --跳到jxcbook意思就是在jxcbook下创建表
go
create table [商品清单] 创建表
(
id int identity(1,1) primary key, --一下是表内容,可以增加其它字段
Goods nvarchar(30)
)

回答4:

CREATE TABLE
[ database_name . [ schema_name ] . | schema_name . ] table_name
[ AS FileTable ]
( { |
| | [ ] [ ,...n ] } )
[ ON { partition_scheme_name ( partition_column_name ) | filegroup
| "default" } ]
[ { TEXTIMAGE_ON { filegroup | "default" } ]
[ FILESTREAM_ON { partition_scheme_name | filegroup
| "default" } ]
[ WITH ( [ ,...n ] ) ]
[ ; ]

::=
column_name
[ FILESTREAM ]
[ COLLATE collation_name ]
[ NULL | NOT NULL ]
[
[ CONSTRAINT constraint_name ] DEFAULT constant_expression ]
| [ IDENTITY [ ( seed ,increment ) ] [ NOT FOR REPLICATION ]
]
[ ROWGUIDCOL ] [ [ ...n ] ]
[ SPARSE ]

::=
[ 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" } ]
]

::=
column_set_name XML COLUMN_SET FOR ALL_SPARSE_COLUMNS

< 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 )
}
::=
{
[DATA_COMPRESSION = { NONE | ROW | PAGE }
[ ON PARTITIONS ( { | }
[ , ...n ] ) ]]
[ FILETABLE_DIRECTORY = ]
[ FILETABLE_COLLATE_FILENAME = { | database_default } ]
[ FILETABLE_PRIMARY_KEY_CONSTRAINT_NAME = ]
[ FILETABLE_STREAMID_UNIQUE_CONSTRAINT_NAME = ]
[ FILETABLE_FULLPATH_UNIQUE_CONSTRAINT_NAME = ]
}

::=
{
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}
| DATA_COMPRESSION = { NONE | ROW | PAGE }
[ ON PARTITIONS ( { | }
[ , ...n ] ) ]
}

回答5:

当然可以用sql语句建表

create table txxx (col1 int not null,col2 char(30),col3 datetime,...)
详细的搜索一下create table