如何用sql语句将某列设为主键

如何用sql语句将某列设为主键,第1张

先执行:
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语句将某列设为主键、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9451771.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存