码迷,mamicode.com
首页 > 数据库 > 详细

SQL语句新建表,同时添加主键、索引、约束

时间:2016-01-26 11:59:27      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:

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语句新建表,同时添加主键、索引、约束

标签:

原文地址:http://www.cnblogs.com/wangfuyou/p/5159648.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!