Click to See Complete Forum and Search --> : how to reset the mysql table id?


jason21
10-27-2007, 01:27 PM
hi,
in sqlserver we have this:
DBCC CHECKIDENT (" table ", RESEED, 0) to reset the id to 0 or other value that we want but in mysql how can i do that?
thanks a lot for your help
:)

NogDog
10-27-2007, 04:31 PM
From http://dev.mysql.com/doc/refman/5.0/en/alter-table.html:

To change the value of the AUTO_INCREMENT counter to be used for new rows, do this:

ALTER TABLE t2 AUTO_INCREMENT = value;

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, you can use ALTER TABLE ... AUTO_INCREMENT = value as of MySQL 5.0.3, but if the value is less than the current maximum value in the column, no error occurs and the current sequence value is not changed.