updating "AUTO_INCREMENT" value in a MySQL table

Submitted by boaz on Thursday, May 10, 2012.

Often when developing SQL backed application one will want or need to "edit" the value of the primary key, typically a simple integer, that is assigned automatically to newly created rows, of course when the table was defined as such. 

If you need to zero your primary key value, when you "TRUNCATE TABLE..." that will do the trick.

If you want to set it to specific value, use: ALTER TABLE table_name AUTO_INCREMENT = 123;

Peace.

Leave a Comment

Fields with * are required.