So, the simple MySQL table, the ID is the primary key, and it is growing from.
ID value1 ok2 Good
Now I delete the above two records, the whole table is an empty table, and then I add a record (directly fill in the value, do not indicate the primary key).
He became:
ID value3 new
ID starting from 3, the previous ID record was deleted by me, his ID how to start from 3, what is the meaning of this?
Reply to discussion (solution)
If you use the empty command, you will not start from 3.
The self-increment primary key is like this, you truncate table; And then starting from 1.
Clear the table, or reset the Auto_increment
The difference between delete and truncate:
Delete from table name Delete is not returned;
TRUNCATE TABLE name when the table is emptied, the primary key automatically increases the value to the bit.
Landlord if the MySQL database does not understand, you can go to see Hanzhongkang Teacher's MySQL video tutorial!
ID int PRIMARY KEY auto_incrmement autogrow does not delete ID, ID does not automatically return to 0