Re: phpMyAdmin--resetting auto increments to 0

From: Date: Sun, 16 Apr 2006 14:03:57 +0000
Subject: Re: phpMyAdmin--resetting auto increments to 0
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-234078@lists.php.net to get a copy of this message
At 4:46 PM +1000 4/16/06, alex wrote:
hi everyone i have delete a few entries in my database as they were entered for testing purposes and are no longer need (actually 102 entries)... and even thought that db is empty i noticed that when the next entry went in the id number went to 103 not 0 so i was wondering is it possible to somehow reset the value to zero... it is of int type and auto_increment i have a few db's which id like to reset to zero i have tried placing a zero enrty after deleting the lot but it only jumps to its next increment. does anyone know what i mean...? any help will be grateful regards alex
Alex: This always works for me in mySQLAdmin. 1. Delete the first record. 2. Reset the auto_increment to whatever you want. 3. Insert a record. 4. Delete that record. After that, the next record will start at the new auto_increment. Don't ask why, that's just the way it works. If you want to reset the ID from within php, try this: // Renumber the Existing 'id' Sequence alter table $table_name drop id, add id int unsigned not null auto_increment first, auto_increment = 1; But, don't tell anyone that you did it AND especially don't tell anyone I gave you the code. This is a big "no-no" as decreed by the dB Gods and is seldom committed to written word. :-) tedd -- -------------------------------------------------------------------------------- http://sperling.com

« previous php.general (#234078) next »