MS SQL创建数据表+设置主键+设置唯一约束

CREATE TABLE[employee](
 
         [EmployeeID][char](9) NOT NULL CONSTRAINT[PK_employee]PRIMARY KEY CLUSTERED,  /*设置主键*/
         [Name][varchar](10) NOT NULL,
         [Sex][bit]NOT NULL,
         [Birthday][smalldatetime]NOT NULL,
         [Birthplace][varchar](10) NOT NULL,
         [ID][char](18) NOT NULL CONSTRAINT[IX_ID]UNIQUE NONCLUSTERED([ID]ASC),   /*设置唯一约束*/
)
ON[PRIMARY]

 

 

 

CREATE TABLE[employee](
 
 [EmployeeID][char](9) NOT NULL CONSTRAINT[PK_employee]PRIMARY KEY CLUSTERED,
 [Name][varchar](10) NOT NULL,
 [Sex][bit]NOT NULL,
 [Birthday][smalldatetime]NOT NULL,
 [Birthplace][varchar](10) NOT NULL,
 [ID][char](18) NOT NULL CONSTRAINT[IX_ID]UNIQUE NONCLUSTERED([ID]ASC),
)
ON[PRIMARY]

ALTER TABLE [employee] add constraint [PK_employee]PRIMARY KEY CLUSTERED ([EmployeeID] ASC)
ON [PRIMARY]

ALTER TABLE [employee] add constraint [IX_employee]UNIQUE NONCLUSTERED([ID]ASC)
ON [PRIMARY]

 

阅读剩余
THE END