This blog site is not meant to be any information that is distributed to the general public. It is to serve as shared documentation between the DNSTC developers; however, if you find something useful and would like to use it, go right ahead.

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