Mysql,将数据排序后重新插入表中sql语句(自增主键ID)
记录一下sql语句(目的为了使数据从头开始自增)
create table tabr_20201123 like table1;
insert into tabr_20201123 select * from table1;
delete from table1;
insert into table1(customer_id,…)
select customer_id,… from tabr_20201123 order by id;
完事后可以设置AUTO_INCREMENT的值为ID最大值+1
ALTER TABLE table1
AUTO_INCREMENT=1;
设置的值存在的话,会自动设置最大值+1。