SQL语句新建表,同时添加主键索引约束
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL语句新建表,同时添加主键索引约束相关的知识,希望对你有一定的参考价值。
SQL语句新建数据表 主键,索引,约束
CREATE TABLE [dbo].[T_SendInsideMessageRec]( [SendInsideMID] [uniqueidentifier] NOT NULL, [ReceiveMobile] [nvarchar](20) NULL, [SendTime] [datetime] NULL, [Content] [nvarchar](200) NULL, [result] [nvarchar](100) NULL, [remark] [nvarchar](100) NOT NULL, CONSTRAINT [PK_T_SendInsideMessageRec] PRIMARY KEY NONCLUSTERED ( [SendInsideMID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[T_SendInsideMessageRec] ADD CONSTRAINT [DF_T_SendInsideMessageRec_SendInsideMID] DEFAULT (newid()) FOR [SendInsideMID] GO ALTER TABLE [dbo].[T_SendInsideMessageRec] ADD CONSTRAINT [DF_T_SendInsideMessageRec_ReceiveMobile] DEFAULT (‘‘) FOR [ReceiveMobile] GO ALTER TABLE [dbo].[T_SendInsideMessageRec] ADD CONSTRAINT [DF_T_SendInsideMessageRec_SendTime] DEFAULT (getdate()) FOR [SendTime] GO ALTER TABLE [dbo].[T_SendInsideMessageRec] ADD CONSTRAINT [DF_T_SendInsideMessageRec_Content] DEFAULT (‘‘) FOR [Content] GO ALTER TABLE [dbo].[T_SendInsideMessageRec] ADD CONSTRAINT [DF_T_SendInsideMessageRec_result] DEFAULT (‘‘) FOR [result] GO ALTER TABLE [dbo].[T_SendInsideMessageRec] ADD CONSTRAINT [DF_T_SendInsideMessageRec_remark] DEFAULT (‘‘) FOR [remark] GO
以上是关于SQL语句新建表,同时添加主键索引约束的主要内容,如果未能解决你的问题,请参考以下文章