Hi, recently I have come across this small issue and would like to share it with you.
After deleting all records from the table, and inserting new rows I noticed the primary key continue to increment from the last (old) id. Because of the foreign key constraints I could not even drop the table without extra burden.
Luckily trying the following simple sql statement easily solves the problem:
ALTER TABLE table_name AUTO_INCREMENT = initialValue
Here the initialValue can be 1 or any integer value.
Cool isn't it ?
After deleting all records from the table, and inserting new rows I noticed the primary key continue to increment from the last (old) id. Because of the foreign key constraints I could not even drop the table without extra burden.
Luckily trying the following simple sql statement easily solves the problem:
ALTER TABLE table_name AUTO_INCREMENT = initialValue
Here the initialValue can be 1 or any integer value.
Cool isn't it ?
No comments:
Post a Comment