Solve the problem of discontinuous auto-increment ID after deleting data in MySQL table

a background

      Encountered a problem, that is, when processing online data, some data does not meet the requirements and needs to be deleted; and then re-insert new data, the only requirement is to maintain the continuity of the auto-increment ID, that is, according to 1, 2, 3, 4, 5, 6. . . . . This order increases, and after querying the information, it is finally solved.

Two examples

      To simplify the problem I encountered, there is a table in the online database, let’s call it user, and the table creation statement is as follows:

CREATE TABLE `user` (
  `id` int(11) unsigned NOT 

Guess you like

Origin blog.csdn.net/whq19890827/article/details/127855395