After deleting a piece of data in mysql database, the problem of discontinuous primary key id is solved

question

In order to ensure the consistency of the primary key in the database, when a primary key value is occupied, even if the data is deleted, the primary key is still unavailable, which leads to the problem of discontinuous primary key.

Not much to say, directly on the solution

Execute the following SQL statement to reset the id auto-increment

set @i=0;
update product set product.id=(@i:=@i+1);

Explanation: Reset the auto-increment column (id) of the table (product)

Guess you like

Origin blog.csdn.net/qq_43813351/article/details/128536257