Fira Posted September 24, 2006 Share Posted September 24, 2006 Is it possible to change the order of the columns in a table? Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 24, 2006 Share Posted September 24, 2006 Why would you want to do that? It's the order in which you display retrieved data that's important, isn't it? Quote Link to comment Share on other sites More sharing options...
Fira Posted September 24, 2006 Author Share Posted September 24, 2006 [quote author=AndyB link=topic=109239.msg440162#msg440162 date=1159060412]Why would you want to do that? It's the order in which you display retrieved data that's important, isn't it?[/quote]Yes, but one of my primary indices "id" is listed as my sixth column. It'd be easier to browse and keep track if I could change the position of "id" to first position. Quote Link to comment Share on other sites More sharing options...
shoz Posted September 24, 2006 Share Posted September 24, 2006 I don't know of a way to move the column only. You can use the CHANGE and MODIFY options for "ALTER TABLE" to move it but you'll have to redefine the column.eg:[code]ALTER TABLE tablename MODIFY columnname INT NOT NULL AUTO_INCREMENT FIRSTorALTER TABLE tablename MODIFY columnname INT NOT NULL AUTO_INCREMENT AFTER othercolumn[/code]http://dev.mysql.com/doc/refman/4.1/en/alter-table.htmlBe careful when writing the column definition. If the wrong definition is given you may alter the contents of the column. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 25, 2006 Share Posted September 25, 2006 There isn't a way to move a column because it's totally unnecessary. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.