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

版权声明:The content of the article comes from WangTwoThree https://blog.csdn.net/weixin_41287692/article/details/86138133

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

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

alter table node_table add id int

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

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

猜你喜欢

转载自blog.csdn.net/weixin_41287692/article/details/86138133