After mysql auto-increment and deletion, the solution to adding data id will not follow: first open the Mysql code editor; then after deleting 4, execute the relevant sql statement, the code is [ALTER TABLE table_name AUTO_INCREMENT = 1 ;].
After mysql is added and deleted, the added data id will not be followed immediately. Solution:
Problem: mysql After deleting the auto-incremented id data from the table, the ids will not follow when adding data again.
For example:
Auto-increment id
1 2 3 4
Now delete 4, it becomes
1 2 3
At this time, if you add a piece of data, it will become
1 2 3 5
The above 5 is not the result we want, 4 is the ideal id,
The solution is to execute the following sql statement after deleting 4:
ALTER TABLE table_name AUTO_INCREMENT = 1;
Related free learning: mysql database(database)
The above is the detailed content of What should I do if the added data ID does not follow immediately after mysql auto-increment and deletion?. For more information, please follow other related articles on the PHP Chinese website!