Is there a way to fix ID sequence in a MySQL table using PHP?
Basically I have some tables with a lot of records, 1000 to 5000. ‘ID’ is
the Primary Key column in these tables, and at the time the code was
originally written, there weren’t much verification of data being input going on. Thus a lot of junk records were being let in, which had to be deleted at some point or another. Now the ID sequence is all screwed up.
It’s not in sequence anymore.

You may not like this answer but you shouldn't "fix" this. Primary keys, by definition, should never change. Their purpose is to uniquely refer to a record. If you change the primary key of a record, then you've undermined this purpose.

If you have "holes" in your sequencing, this isn't a problem either, as how the records are stored in the database is completely meaningless. If you need the records to be listed in some sort of order, you should add another column or table that manages that. But leave the primary key alone.

Hope that helps,
Larry
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to