How do I change the order of my table fields without deleting the field and re-inserting it, using PHP myAdmin?
如何在不刪除字段並使用myphp admin重新插入表字段的情況下更改表字段的順序?
8 个解决方案
#1
65
ALTER TABLE `table_name` MODIFY `column_you_want_to_move` DATATYPE AFTER `column`
DATATYPE is something like DATETIME or VARCHAR(20) ..etc
數據類型類似於DATETIME或VARCHAR(20) .等等
#2
22
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之后。
#3
21
If you have phpMyAdmin 4.0.0+, you can use the phpMyAdmin Feature under Structure:
如果您有phpMyAdmin 4.0.0+,您可以在以下結構中使用phpMyAdmin特性:
#4
9
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:
如果你決定改變表格列的順序,你可以這樣做:
Create a new table with the columns in the new order.
用新順序中的列創建一個新表。
Execute this statement:
執行這個語句:
mysql> INSERT INTO new_table -> SELECT columns-in-new-order FROM old_table;
將mysql>插入到new_table ->中,從old_table中選擇新訂單;
Drop or rename old_table.
或者重命名old_table下降。
Rename the new table to the original name:
將新表重命名為原始名稱:
mysql> ALTER TABLE new_table RENAME old_table;
mysql> ALTER TABLE new_table重命名old_table;
#5
8
Since version 4.0, phpMyAdmin has a "Move columns" dialog in Structure, that permits you to graphically move columns in the structure.
由於版本4.0,phpMyAdmin在結構上有一個“移動列”對話框,允許您在結構中以圖形方式移動列。
#6
3
alter table table_name modify column col_name type after col_name
#7
1
Another alternative:
另一個選擇:
CREATE new_table SELECT columns-in-new-order FROM old_table;
#8
1
if you have MySQL Workbench you can easily reorder columns using mouse, graphically.
如果你有MySQL工作台,你可以很容易地用鼠標重新排列列,圖形化。
Just connect to your database, select your table and after right click, alter table and then drag columns to reorder them.
只要連接到您的數據庫,選擇您的表,然后右鍵單擊,alter table,然后拖動列來重新排序它們。