5

Is it possible to change the order of columns in MySQL (using phpMyAdmin XAMPP) by which they appear without dropping the current table?

informatik01
  • 16,038
  • 10
  • 74
  • 104
manojadams
  • 2,314
  • 3
  • 26
  • 30

3 Answers3

11

Try this

ALTER TABLE `table_name`
    MODIFY COLUMN `column_name1` varchar(100) AFTER `column_name2`;
informatik01
  • 16,038
  • 10
  • 74
  • 104
V A S
  • 3,338
  • 4
  • 33
  • 39
5

I'm not sure about phpMyAdmin, but you can certainly do that with an SQL query:

ALTER TABLE `table`
CHANGE COLUMN `oldname` `newname` *column_definition* [AFTER|BEFORE] `colname`;
informatik01
  • 16,038
  • 10
  • 74
  • 104
abresas
  • 835
  • 6
  • 7
2

How to do it by using PhpMyAdmin:

  • Show table structure
  • On the relevant row (i.e. database column) click on "Modify"
  • On the extreme right, choose the new position form the "Move field" combo box
  • Optionally, click on "Show preview" to see what SQL query will be run (also useful for automatically repeating the procedure in another instance of the same database)
  • After closing the preview box, click on "Save"

Done!

Giorgio Barchiesi
  • 6,109
  • 3
  • 32
  • 36