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

时间:2023-03-08 17:44:44

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