PHP myAdmin - 更改字段顺序(向上或向下移动)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1962448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:28:22  来源:igfitidea点击:

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

phpmysqlphpmyadmin

提问by Joshua

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

如何使用 PHP myAdmin 更改表字段的顺序而不删除该字段并重新插入它?

回答by Populus

ALTER TABLE `table_name` MODIFY `column_you_want_to_move` DATATYPE AFTER `column`

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

DATATYPE 类似于 DATETIME 或 VARCHAR(20) ..etc

回答by TecBeast

If you have phpMyAdmin 4.0.0+, you can use the phpMyAdmin Feature under Structure:

如果您有 phpMyAdmin 4.0.0+,则可以使用 Structure 下的 phpMyAdmin 功能:

回答by Ashish

Something like this will help

这样的事情会有所帮助

ALTER TABLE Person MODIFY COLUMN last_name VARCHAR(50) AFTER first_name;

This will move last_nameright after first_namein order.

这将移动last_name之后first_name才能。

回答by Sampson

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

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;

  1. 使用新顺序中的列创建一个新表。

  2. 执行这个语句:

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

  3. 删除或重命名 old_table。

  4. 将新表重命名为原始名称:

    mysql> ALTER TABLE new_table RENAME old_table;

回答by Marc Delisle

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 在结构中有一个“移动列”对话框,允许您以图形方式移动结构中的列。

回答by Cruz

alter table table_name modify column col_name type after col_name

回答by user2145716

Another alternative:

另一种选择:

CREATE new_table SELECT columns-in-new-order FROM old_table;

回答by Peyman abdollahy

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

如果您有MySQL Workbench,您可以轻松地使用鼠标以图形方式重新排序列。

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

只需连接到您的数据库,选择您的表,然后右键单击,更改表,然后拖动列以重新排序它们。

回答by Joseph Adegbola

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.

这很简单。只需转到 PHPmyadmin,单击您的数据库,然后单击表。然后点击结构。在表格下方查找按钮“移动列”。单击并按照您想要的方式对列进行排序。