PHP MySQL – Return your database table autoincrement back to 1

Database tables that auto increment generally start at 1 and keep on going up, even if all the content in the table has been deleted, the next entry will continue on from the last number.

If you would like to delete all the content from a database table and restart your table to number 1 this is how you do it.

In phpMyAdmin click on the table name that you want to reset. For this example lets call it table1.

Click on the SQL tab at the top of the page.

In the SQL box delete the default text that is there (if any).

Enter this:
DELETE FROM table1;
ALTER TABLE table1 AUTO_INCREMENT=1;

Click on go and that is that.

All the content from the table is deleted and the auto increment is reset to one.

A second method which is really easy is to go to PHP Admin. Select the table e.g. Table1

Click on the Trash can tab (empty) at the top of the page.

A pop asks ” Do you want to Truncate table Table1″.

Click OK and it is done.

Related Posts

Leave a Reply

Name (Required)

Email (Required - will not be published)

Website

Message (Required)