mysql 给已经存在数据的表添加一个自增的id

2022-07-20 浏览 (1901)

mysql 给已经存在数据的表添加一个自增的id

先添加字段id

alter table test_table add id int;

修改字段id的属性

alter table test_table change id id int not null auto_increment primary key;
  • 所属分类: 后端技术
  • 本文标签: mysql
  • 版权声明: 本文链接 https://seaxiang.com/blog/cDXWu4