Solve the problem of discontinuous ID self-increment after MySQL deletes data

before repair

In addition to some data, resulting in subsequent new data, ID self-increment is not continuous

 

solution

  • Execute the following SQL statement to fix this problem, mbs_order is the name of the table that needs to be fixed
  • SET @i=0;
    UPDATE `mbs_order` SET `id`=(@i:=@i+1);
    ALTER TABLE `mbs_order` AUTO_INCREMENT=0;

     

Guess you like

Origin blog.csdn.net/WQGuang/article/details/132096274