Primary key in SQL Statements

--A)建立和撤销自动增长列--(在现有表结构中新增字段)
/*撤消主键*/
alter table [Student] drop primary key (S_id)
/*增加主键*/
alter table [Student] add primary key (S_id)
go
alter table xyf_成品出口耗用保税料件明细 add Pkey int primary key identity(1,1)
go
--B)新建表结果中添加自动增长标识列

create table MyTable
(
      Id           int                 primary key identity(1,1),--主键,自动+1
      name      varchar(20)    unique not null,--不允许重复,不允许为空
      Age        tinyint,
      Dates     smalldatetime default getdate()
)

原文地址:https://www.cnblogs.com/Fandyx/p/1761304.html