Home » Performance » MySQL » Reorder ID column
Reorder ID column [message #1341] Wed, 30 May 2007 18:44 Go to next message
GeoffreyF67  is currently offline GeoffreyF67
Messages: 21
Registered: May 2007
Junior Member

Anyone know of an easy way to reorder an PRIMARY auto increment column that has lots of holes in it?

G-Man


G-Man
Re: Reorder ID column [message #1343 is a reply to message #1341 ] Thu, 31 May 2007 06:50 Go to previous messageGo to next message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
Yes, you don't!
That's the purpose of the primary key to hold unique keys.

What is your reason to do this, it looks messy or?
Unless you have a _very_ good reason to do it you generally leave it as it is.
Re: Reorder ID column [message #1351 is a reply to message #1341 ] Fri, 01 June 2007 05:38 Go to previous messageGo to next message
Speeple  is currently offline Speeple
Messages: 91
Registered: August 2006
Member
Agree with the above post, and if you reordered a relational table setup the relation ships would have to reflect the changes.

If there are no relationships to be lost, then you could just CREATE TABLE LIKE... called table_new

Then do INSERT INTO table_new (id, column1 ...) SELECT null, column1 ... FROM table_old;


Martin Gallagher | Speeple: The latest news
Re: Reorder ID column [message #1353 is a reply to message #1341 ] Fri, 01 June 2007 18:52 Go to previous message
GeoffreyF67  is currently offline GeoffreyF67
Messages: 21
Registered: May 2007
Junior Member

LOL. That's a great point.

Upon further reflection I'm going to leave it as it is.

I was looking around and found a link to a way to get random values even when you have gaps so that'll work just fine for me.

And, mostly, this was just a case of "cuz it looks 'bad'" Razz

Thanks!


G-Man
Previous Topic:Is MySQL Case Sensitive
Next Topic:Fastest Way to Remove Duplicates
Goto Forum:
  


Current Time: Sun Jul 5 15:44:27 EDT 2009

Total time taken to generate the page: 0.01189 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.