Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rearrange a table? 1

Status
Not open for further replies.

theEclipse

Programmer
Dec 27, 1999
1,190
US
There is no pressing need to do this...just laziness really.

Is there a way to rearrange the left-to-right order that mysql thinks of my tables? I have some databases that were setup with a bunch of boolean values and the real data fields afterwords. When I [tt]SELECT * FROM table[/tt] I have to scroll waaay over in order to get to the stuff that I am looking for.

Just curious.

Thanks

Robert Carpenter
Remember....eternity is much longer than this ~80 years we will spend roaming this earth.
ô¿ô
 
create a new table as select in the order you want. drop the old table. rename the new one. don't forget the indexes.

-----------------------------------------
I cannot be bought. Find leasing information at
 
Actually, you can do this with an ALTER TABLE statement. The only annoyance is that you need to re-specify the column definition. For example, this will move col1 to be after col2:
Code:
ALTER TABLE yourtable MODIFY COLUMN col1 VARCHAR(50) NOT NULL AFTER col2;
 
You could of course just be specific in your SELECT statements to get the order you want.

Code:
SELECT field5, field10, field1 FROM mytable...

Will return them in that order even though the column definitions would put them fiedl1,...field5,...field10 etc...;







----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top