mysql给已有表新增自增字段

451 阅读1分钟

1、新增字段

alter table user add id int; // 新增id字段

2、修改id字段为自增字段

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