Page 1 of 1
resetting ID incremental field with phpMyAdmin
Posted: Tue Jul 09, 2002 3:55 pm
by fariquzeli
I've been deleting ID's and test records from my tables, I was just wondering how to get it to restart at 0. Cause now with an empty table my first record is starting at like 13, and so on.
any help?
Posted: Tue Jul 09, 2002 4:04 pm
by calebsg
saw this on mysql.com the other day:
I finally figured out how to reset the AUTO_INCREMENT counter: ALTER TABLE tbl_name AUTO_INCREMENT = 1;
see if that works
Posted: Tue Jul 09, 2002 4:10 pm
by fariquzeli
thanks a bunch, works great.
Posted: Wed Jul 10, 2002 2:10 am
by twigletmac
If you're deleting all the information from a table, instead of doing it row by row just empty the data instead.
Then the auto-increment field is automatically reset.
Mac
Auto_Increment rules
Posted: Fri Jul 12, 2002 12:50 pm
by EricS
Prior to MySQL 3.23
Auto_Increment would always increment from the highest value found in the table. So deleting all the rows one-by-one or all at once would reset the counter.
As of MySQL 3.23
Auto_Increment in only forward sequential and will not reuse previous values even when they are erased. You must do a DELETE FROM tbl_name. This is because this command not only erases the rows but RESETS the table as well, which resets the counter.
FFR