lundi 2 mars 2015

MySQL ALTER TABLE table_name AUTO_INCREMENT=1 doesn't work


I'm using yii and it's test system. Yii's fixture manager resets tables and their AI keys so:



DELETE FROM table_name;
ALTER TABLE table_name AUTO_INCREMENT = 1;


It was working good on server before that moment, when i upgraded to mysql 5.6.


Now i can't set AI for the table less, than it was before, e.g.:



CREATE TABLE new_table (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id));
// AI = 1
ALTER TABLE new_table AUTO_INCREMENT = 7;
// AI = 7
ALTER TABLE new_table AUTO_INCREMENT = 1;
// AI is still 7


But it must work, because there is no any row in the table.


How is it possible and how it could be fixed?


P.S.: on my vagrant machine i have mysql 5.5 and resetting AI key is working properly.





Aucun commentaire:

Enregistrer un commentaire