How to change the order of fields in a table without deleting this field and pasting it using PHP myAdmin?
ALTER TABLE `table_name` MODIFY `column_you_want_to_move` DATATYPE AFTER `column`
DATATYPE is something like DATETIME or VARCHAR (20) .etc
Something like this will help
ALTER TABLE Person MODIFY COLUMN last_name VARCHAR(50) AFTER first_name;
This will move last_name right after first_name in order.
last_name
first_name
If you have phpMyAdmin 4.0.0+, you can use the phpMyAdmin function in the Structure section:
http://dev.mysql.com/doc/refman/5.0/en/change-column-order.html
If you decide to reorder the columns of the table, you can do this as follows:
Create a new table with columns in a new order.
Do the following:
mysql> INSERT INTO new_table -> SELECT columns-in-new-order FROM old_table;
INSERT INTO new_table -> SELECT columns-in-new-order FROM old_table;
Undo or rename old_table.
Rename the new table to the original name:
mysql> ALTER TABLE new_table RENAME old_table;
ALTER TABLE new_table RENAME old_table;
Starting with version 4.0, phpMyAdmin has a dialog "Move columns" to "Structure", which allows you to graphically move columns in the structure.
alter table table_name modify column col_name type after col_name
Another alternative:
CREATE new_table SELECT columns-in-new-order FROM old_table;
if you have MySQL Workbench , you can easily arrange the columns with the mouse graphically.
Just connect to your database, select your table and right-click, modify the table, and then drag the columns to reorder them.