PHP myAdmin - Change Field Order (Move Up Or Down)

2020-02-17 04:18发布

How do I change the order of my table fields without deleting the field and re-inserting it, using PHP myAdmin?

9条回答
家丑人穷心不美
2楼-- · 2020-02-17 04:36

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

From the Aforementioned Source:

If you decide to change the order of table columns anyway, you can do so as follows:

  1. Create a new table with the columns in the new order.

  2. Execute this statement:

    mysql> INSERT INTO new_table -> SELECT columns-in-new-order FROM old_table;

  3. Drop or rename old_table.

  4. Rename the new table to the original name:

    mysql> ALTER TABLE new_table RENAME old_table;

查看更多
走好不送
3楼-- · 2020-02-17 04:36

if you have MySQL Workbench you can easily reorder columns using mouse, graphically.

Just connect to your database, select your table and after right click, alter table and then drag columns to reorder them.

查看更多
霸刀☆藐视天下
4楼-- · 2020-02-17 04:40
alter table table_name modify column col_name type after col_name
查看更多
Evening l夕情丶
5楼-- · 2020-02-17 04:44
ALTER TABLE `table_name` MODIFY `column_you_want_to_move` DATATYPE AFTER `column`

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

查看更多
放我归山
6楼-- · 2020-02-17 04:48

Since version 4.0, phpMyAdmin has a "Move columns" dialog in Structure, that permits you to graphically move columns in the structure.

查看更多
做个烂人
7楼-- · 2020-02-17 04:51

It's simple. Just go to PHPmyadmin, click on your database, then click table. Then click on structure. Below the table look for the button, "Move columns". Click and order the columns the way you want.

查看更多
登录 后发表回答