такой запрос не работает
Код: Выделить всё
ALTER TABLE `ServicesGroups` AUTO_INCREMENT=((SELECT MAX(`ID`) FROM `ServicesGroups`) + 1)
процедуры нету, не сохранил, блин.
может способ проще есть - просто я не знаю?
Модератор: terminus
Код: Выделить всё
ALTER TABLE `ServicesGroups` AUTO_INCREMENT=((SELECT MAX(`ID`) FROM `ServicesGroups`) + 1)
Код: Выделить всё
ALTER TABLE `dishs` AUTO_INCREMENT =300
Код: Выделить всё
ALTER TABLE `ServicesGroups` auto_increment = MAX(`ID`) + 1
Но вообще вот что пишут -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.
Но вообще это всё не ясно зачем надо. Потому как auto_increment все равно всегда берет MAX и прибавляет инкремент. Так что руками выставлять его в MAX+1 смысла не имеет.If you use "ALTER TABLE mytable AUTO_INCREMENT = N" the MySQL server will create a new table, copy all the data from the old table to the new, delete the old and then rename the new one even though there is no structural change to the table. The server response will show that all the rows have been "affected", like this:
mysql> alter table mytable auto_increment=1000000;
Query OK, 512691 rows affected (1 min 4.55 sec)
Records: 512691 Duplicates: 0 Warnings: 0
There are potential issues that may arise from the table copy, especially if you didn't expect it! I.e. is there a sufficient amount of free disk space for the second copy of the data, etc., etc..
The bottom line for me is to go back to the "old fashioned way" - just insert a dummy row and explicitly set the AUTO_INCREMENT column to N - 1, then immediately delete the dummy row. The next row that is inserted will start at N and go from there.
я знаю. но таблица - InnoDBFiL писал(а):какой тип таблицы? В MyISAM можешь выставлять его в 0.
незнал... завтра попробую... чё-то у провайдера, блин, инет тупит со страшной силойFiL писал(а):Но вообще это всё не ясно зачем надо. Потому как auto_increment все равно всегда берет MAX и прибавляет инкремент. Так что руками выставлять его в MAX+1 смысла не имеет.
Код: Выделить всё
UPDATE `ServicesGroups` SET `ID`=(`ID` + 1000) WHERE `ID` > 1000;