reset Auto Number

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

reset Auto Number

Post by Illusionist »

Does anyoen know how to reset an Auto Increment feild back to 0, or 1 for a mysql table?? Because i'm, developing an app and filling the databse with bogus data for testing and i would liek to reset the Auto Increment field back t zero without having to recreate that field... I hope there is another way! Thanks
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

TRUNCATE <tablename>

This will remove all the entries in the table and reset the auto inc column.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

cool! Thanks
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

ALTER TABLE `tableName` AUTO_INCREMENT=0;
Post Reply