Friday, April 18, 2008

Resetting the Auto Increment

Here is a little trick I have picked up in my travels… when you load information into a MySQL database that has an auto increment for the key, those keys can become quite large. Especially if you continue to delete/load records into the database.

You can use the following to reset the key (Or change it to whatever you want):

Perform this after a deletion…
$fixIt = "ALTER TABLE inventory AUTO_INCREMENT = 1";
mysql_select_db($database_experience, $experience);
$Result1 = mysql_query($fixIt, $experience) or die(mysql_error());

No comments:

Post a Comment