對數據表操作之前備份一下是個好習慣
1.備份表結構
create table 備份表名 like 表名;
2.備份表數據
insert into 備份表名 select * from 表名;
3.刪除原來主鍵字段(如id)
alter table 表名 drop id;
4.添加主鍵,自增,放在第一位
alter table 表名 add id int(11) primary key auto_increment first;
5.檢查沒問題的話,備份的表可以刪了
delete from 備份表名;