PHP myAdmin - Reorder fields (move up or down)

How to change the order of fields in a table without deleting this field and pasting it using PHP myAdmin?

+52
php mysql phpmyadmin
Dec 26 '09 at 2:06
source share
8 answers
ALTER TABLE `table_name` MODIFY `column_you_want_to_move` DATATYPE AFTER `column` 

DATATYPE is something like DATETIME or VARCHAR (20) .etc

+65
Apr 15 '11 at 5:45
source share

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.

+22
05 Oct '12 at 8:45
source share

If you have phpMyAdmin 4.0.0+, you can use the phpMyAdmin function in the Structure section:

At0PCyB.jpg

+21
Nov 26 '14 at 13:42 on
source share

http://dev.mysql.com/doc/refman/5.0/en/change-column-order.html

From the above source:

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;

  • Undo or rename old_table.

  • Rename the new table to the original name:

    mysql> ALTER TABLE new_table RENAME old_table;

+9
Dec 26 '09 at 2:10
source share

Starting with version 4.0, phpMyAdmin has a dialog "Move columns" to "Structure", which allows you to graphically move columns in the structure.

+8
Aug 23 '13 at 19:30
source share
 alter table table_name modify column col_name type after col_name 
+3
Oct 14 '11 at 20:41
source share

Another alternative:

 CREATE new_table SELECT columns-in-new-order FROM old_table; 
+1
Mar 20 '14 at 2:23
source share

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.

+1
Mar 09 '15 at 7:16
source share



All Articles