RE: [PHP-DB] Authomatic Sorting

From: Date: Wed, 11 Jul 2001 21:11:42 +0000
Subject: RE: [PHP-DB] Authomatic Sorting
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10304@lists.php.net to get a copy of this message
<snip> But instead I end up with the following: 001 user1 003 user3 Any idea or comment? </snip> The auto incrementing feature of mysql unfortunately will always increase by 1 based on the (MAX) primary key ID number. Questions about this have been made to the MySQL development team as to if they would make it so MySQL would fill in gaps in the ID key numbers however they said they have no plans for doing such a thing (at least when I last inquired hehe) If you wish to change it so you have the IDs 001 user1 002 user3 You would need to reset the database (ie DELETE FROM table1;) and then repopulate the database with all the information. This of course would reset the IDs for all of the records so make sure it is what you truly wish to do. Another option of course is to never delete any rows and instead have a boolean field you can use to mark active/inactive records and set all your queries to only search records with the active flag. However in my opinion....unless you have a specific reason why you would want all the primary keys to be in order you shouldn't concern yourself with it. As long as you routinely remove all the deleted records from the table having the primary key not in numerical synchronization will not cause you any performance problems. Sincerely, Craig Vincent

« previous php.db (#10304) next »