You are here: Re: [PHP] Fixing ID's in mySQL Table « PHP « IT news, forums, messages
Re: [PHP] Fixing ID's in mySQL Table

Posted by "Larry E. Ullman" on 10/19/37 11:31

> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация