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
can autoincrement field be bring back to 0 or 1?
Moderator: General Moderators
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.
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.
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
.
Code: Select all
TRUNCATE TABLE table_nameSee the TRUNCATE Syntax Entry in the online MySQL manual
.
-
crazycaddy
- Forum Commoner
- Posts: 43
- Joined: Fri Aug 05, 2005 6:59 am
- Location: England, UK
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
feyd wrote: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.Code: Select all
ALTER TABLE `table_name` AUTO_INCREMENT = XXX