简体   繁体   中英

Change AUTO_INCREMENT value

I'm using MySQL 5.6.12 . I tried this command, but didn't work.

ALTER TABLE food AUTO_INCREMENT = 1;  
ALTER TABLE food AUTO_INCREMENT=1;

I tried with my winform application and by EMS MySQL manager , neither worked.
I Already tried some of the answers I found here, but nothing yet...

No errors at all. The query executes perfect, it just does not change the AUTO_INCREMENT value.

If you're trying to lower the auto increment value, it may not work as you expect. From the MySQL Documentation :

You cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum plus one. For InnoDB, if the value is less than the current maximum value in the column, no error occurs and the current sequence value is not changed.

Since you're trying to set it to 1 , this won't work unless the table is empty, since that's necessarily less than the current maximum value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM