先执行:
alter table 表名
alter column 列名1 int not null
再执行:
alter table 表名 add constraint PK_主键约束 primary key (列名1)
执行第一句前提是表中的“列名1”列没有空值才可以。
例如:
alter table testtab alter column testid int not null
alter table testtab add constraint PrimaryKey primary key (testid)
以上就是关于如何用sql语句将某列设为主键全部的内容,包括:如何用sql语句将某列设为主键、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)