前言:
此刻咱们对“sql怎么创建表”大体比较关怀,我们都需要了解一些“sql怎么创建表”的相关文章。那么小编也在网上汇集了一些关于“sql怎么创建表””的相关文章,希望小伙伴们能喜欢,小伙伴们快快来学习一下吧!创建表
--删除表
--DROP TABLE [dbo].[Test]
--创建表
CREATE TABLE [dbo].[Test] (
[Id] INT NOT NULL IDENTITY(1,1) PRIMARY KEY, ----自增主键
[Name] nvarchar(50) NULL DEFAULT '默认值', ----可设置默认值
[Remarks] nvarchar(MAX) NULL, --------------------字符串类型
[TypeId] int NULL,-------------------------------整型,取值范围[-231~231)
[ServicevalueExcludingVat] MONEY NULL, ----------货币型
[ServicevalueEncludingVat] decimal(12,4) NULL, --精确数值型 共12位,小数点右4位
[VatPercentage] float NULL, ---------------------近似数值型
[AddDate] date NULL , ------------------------------日期
[AddTime] datetime NULL ,---------------------------时间
)
--添加表说明
EXECUTE sp_addextendedproperty N'MS_Description',N'测试表',N'user',N'dbo',N'table',N'Test',NULL,NULL
--删除表说明
--EXEC sp_dropextendedproperty N'MS_Description','user','dbo','table', '表名', NULL,NULL
--添加字段说明
EXECUTE sp_addextendedproperty N'MS_Description',N'名称',N'user',N'dbo',N'table',N'Test',N'column',N'Name'
EXECUTE sp_addextendedproperty N'MS_Description',N'备注',N'user',N'dbo',N'table',N'Test',N'column',N'Remarks'
EXECUTE sp_addextendedproperty N'MS_Description',N'类型',N'user',N'dbo',N'table',N'Test',N'column',N'TypeId'
EXECUTE sp_addextendedproperty N'MS_Description',N'服务价值,不包括增值税',N'user',N'dbo',N'table',N'Test',N'column',N'ServicevalueExcludingVat'
EXECUTE sp_addextendedproperty N'MS_Description',N'服务价值,包括增值税',N'user',N'dbo',N'table',N'Test',N'column',N'ServicevalueEncludingVat'
EXECUTE sp_addextendedproperty N'MS_Description',N'增值税百分比',N'user',N'dbo',N'table',N'Test',N'column',N'VatPercentage'
EXECUTE sp_addextendedproperty N'MS_Description',N'创建日期',N'user',N'dbo',N'table',N'Test',N'column',N'AddDate'
EXECUTE sp_addextendedproperty N'MS_Description',N'创建时间',N'user',N'dbo',N'table',N'Test',N'column',N'AddTime'
--删除字段说明
--EXEC sp_dropextendedproperty N'MS_Description', 'user','dbo', 'table', '表名', 'column','字段名'
创建表