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

 

转载于:https://www.cnblogs.com/wangfuyou/p/5159648.html

你可能感兴趣的:(SQL语句新建表,同时添加主键、索引、约束)