一、ID中断不连续的,重新设置为连续的ID
alter table table_name drop id;
alter table table_name add id int not null first;
alter table table_name modify column id int not null auto_increment, add primary key(id);
select * from table_name order by id;
二、根据日期顺序,重新排列ID
alter table table_name drop id;
alter table table_name add id int not null first;
SET @row_number = 0;
UPDATE table_name
SET id = (@row_number := @row_number + 1)
ORDER BY ref_date;
alter table table_name modify column id int not null auto_increment, add primary key(id);
select * from table_name order by id;
参考文章:

&spm=1001.2101.3001.5002&articleId=144722751&d=1&t=3&u=8343bddff8f84ac3aec29a4c4395c971)
1万+

被折叠的 条评论
为什么被折叠?



