5

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

1

3 Answers 3

11

Try this

ALTER TABLE `table_name`
    MODIFY COLUMN `column_name1` varchar(100) AFTER `column_name2`;
0
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`;
3
  • ...and you can use phpmyadmin to run that query so the answer would be yes. Apr 4, 2012 at 18:59
  • Hi, this showed errors on running the sql query ALTER TABLE 'teachers-final' CHANGE COLUMN 'Field' 'Fields' varchar(20) [AFTER] 'Name'; Any Suggestions?
    – manojadams
    Apr 5, 2012 at 2:30
  • simply AFTER. remove brackets
    – abresas
    Apr 5, 2012 at 21:50
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.