Skip to main content
 首页 » 数据库

MySQl 数据库已有数据的表添加自增 ID

2022年07月19日185JeffreyZhao

数据库导入数据后发现没有自增 id,因此就有了上面这个问题。

解决方法
1、给某一张表先增加一个字段,这里我们就以 node_table 这张表来举例,在数据库命令行输入下面指令 :

alter table node_table add id int 
  • 1

2、更改 id 字段属性为自增属性,在数据库命令行输入下面指令 :

alter table `node_table` change id id int not null auto_increment primary key; 

https://blog.csdn.net/weixin_41287692/article/details/86138133

本文参考链接:https://www.cnblogs.com/xihong2014/p/14309005.html