1、备份表结构

create table table_bak like table_name;

2、备份表数据

insert into table_bak select * from table_name;

3、删除原来主键字段(如id)

alter table table_name drop id;

4、添加主键,自增,放在第一位

alter table table_name add id int(11) primary key auto_increment first;

搞定

5、检查没问题的话,备份的表可以删了

drop table table_name;

相关文章:

  • 2021-04-14
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-05-31
相关资源
相似解决方案