用SQL语句怎么把已存在的列加上IDENTITY属性

用SQL语句怎么把已存在的列加上IDENTITY属性,第1张

只能在新建表,或者修改列时才能设置

create table tb(id int identity(1,1))

alert table tb add kid int identity(1,1)

insert是不用赋值的

自增列不能直接修改,必须将原有ID列删除,然后重新添加一列具有identity属性的ID字段。比如你要修改的字段名为ID:alter table 表名 drop column IDalter table 表名 add ID int identity(1,1)


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

原文地址: http://outofmemory.cn/bake/11732308.html

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

发表评论

登录后才能评论

评论列表(0条)

保存