tsql创建表
发布时间: 2024-01-26 02:51:22
㈠ Test数据库中,用T-sql语句创建员工工资表,各列的要求如 下表所示
CREATETABLEdbo.员工工资
(
NointNOTNULLIDENTITY(1,1),
Xmvarchar(30)NOTNULL,
Gzdecimal(8,2)NOTNULL,
YwJjdecimal(8,2)NOTNULL,
Sdsdecimal(8,2)NOTNULL,
SfGzASGz+YwJj-Sds
)ON[PRIMARY]
GO
DECLARE@vsql_variant
SET@v=N'员工工资'
EXECUTEsp_addextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N'员工工资',NULL,NULL
GO
DECLARE@vsql_variant
SET@v=N'编号'
EXECUTEsp_addextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N'员工工资',N'COLUMN',N'No'
GO
DECLARE@vsql_variant
SET@v=N'姓名'
EXECUTEsp_addextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N'员工工资',N'COLUMN',N'Xm'
GO
DECLARE@vsql_variant
SET@v=N'工资'
EXECUTEsp_addextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N'员工工资',N'COLUMN',N'Gz'
GO
DECLARE@vsql_variant
SET@v=N'业务奖金'
EXECUTEsp_addextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N'员工工资',N'COLUMN',N'YwJj'
GO
DECLARE@vsql_variant
SET@v=N'所得税'
EXECUTEsp_addextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N'员工工资',N'COLUMN',N'Sds'
GO
ALTERTABLEdbo.员工工资ADDCONSTRAINT
PK_员工工资PRIMARYKEYCLUSTERED
(
No
)WITH(STATISTICS_NORECOMPUTE=OFF,IGNORE_DUP_KEY=OFF,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON)ON[PRIMARY]
GO
ALTERTABLEdbo.员工工资SET(LOCK_ESCALATION=TABLE)
GO
㈡ t sql 建好表后如何定义主键
tsql建好表后如何定义主键的方法。
如下参考:
1、打开管理工具,SQLServerManagementStudio连接到数据库。
热点内容