You are here: Re: MYSQL REORDER PRIMARY KEY « PHP SQL « IT news, forums, messages
Re: MYSQL REORDER PRIMARY KEY

Posted by Rik on 07/25/07 13:52

On Wed, 25 Jul 2007 15:44:01 +0200, zach <wackzingo@gmail.com> wrote:

> Is there a way to sort all the data in my database such as alphabetical
> or something, and then once sorted and have all the primary key's redone
> according to the sorted order? I can sort them how I want, but I don't
> know if there is a way to rename the primary id key on all the data once
> sorted.

I guess:
1. Add a field for new primary key.
2. Update using an order by close and a counter.
3. Drop primary key.
4. Create primary key on new field.
5. Possibly drop old field & rename new field. (ALTER TABLE tbl_name
CHANGE old_col_name column_definition )

However, unless your data is static, I'd think doing this is futile. Why
do you need it?
--
Rik Wasmus

 

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

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