Fix Autoincrement problem Print

  • 337

When you delete an record from one table, and you have there an auto_increment record, you will see that mysql keep that record on cache.
Ex. You have 10 rows on your table and you need to delete the last 3, so you have now 7 rows, but when you add the next row (8th), you will see that mysql create it as 11 instead of 8.

To fix it you need to use the command below.

ALTER TABLE tablename AUTO_INCREMENT=111

Where tablename is your table name and 111 is the record you want mysql to start incrementing from.


Was this answer helpful?

« Back