Page 1 of 1
can autoincrement field be bring back to 0 or 1?
Posted: Wed Aug 17, 2005 6:00 am
by saumya
well, i have a mysql table.I have one autoincrement field in it.While trying all my php codes i tried putting values into the table and evrything worked fine.But when it came to do it again, i removed all the datas from table through PhpmyAdmin.Next time i put values in my databse everything worked properly but the autoincrement field does not came back to 0.It just started counting from where it was preveously before deletion of the datas.
Is there anyway to reset it back to 0?
thanks
Posted: Wed Aug 17, 2005 6:32 am
by anjanesh
1. Second Last option (on top) for a table - marked in Red - Empty - click on it and it'll delete all rows from your table and reset all counters - autoincrement to 1.
2. Third Last option (on top) - Operations - most probably last field on page - auto_increment - fill in the text box to whatever number you want.
Posted: Wed Aug 17, 2005 6:36 am
by saumya
oooooooohoooooooooooooohoooooooooooooooooo
that worked.
thank you very much
Posted: Wed Aug 17, 2005 7:03 pm
by Jean-Yves
In code, you can issue the following statement:
Note that this will Empty the table, and reset the autoincrement index to 1, but *only* on supported versions of MySQL and supported versions of certain table types.
See the
TRUNCATE Syntax Entry in the online MySQL manual
.
Posted: Thu Aug 18, 2005 10:28 am
by crazycaddy
Hey, I needed a solution to this too, ive been deleting my table each time and redoing it

Posted: Thu Aug 18, 2005 11:15 am
by feyd
feyd wrote:Code: Select all
ALTER TABLE `table_name` AUTO_INCREMENT = XXX
switch out XXX for the new value you wish, if the PK used that slot, I believe it'll reset to 1 past the max you have.