Is it possible to change the order of columns in MySQL (using phpMyAdmin XAMPP) by which they appear without dropping the current table?
Asked
Active
Viewed 6,032 times
5
-
1Dup: I think http://stackoverflow.com/questions/1962448/php-myadmin-change-field-order-move-up-or-down – Kris.Mitchell Apr 04 '12 at 18:57
3 Answers
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
-
...and you can use phpmyadmin to run that query so the answer would be yes. – d_inevitable Apr 04 '12 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 05 '12 at 02:30
-
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