使用phpadmin重新排列列的顺序

时间:2021-09-09 20:15:31

Any help on re-ordering the columns in MySQL using phpMyAdmin? Is it called cardinality? I have created tables, but need to re-arrange the order of the columns due to an export script i have. It exports based on the arrangements. E.g. I want columns:

使用phpMyAdmin重新排序MySQL中的列有什么帮助吗?它被称为基数吗?我已经创建了表,但是需要重新安排列的顺序,因为我有一个导出脚本。它根据安排出口。例如我想列:

Apple | Cherry | Banana

changed to:

更改为:

Apple | Banana | Cherry

5 个解决方案

#1


40  

Use the ALTER TABLE with MODIFY COLUMN command. Something like:

使用带有修改列命令的ALTER TABLE。喜欢的东西:

ALTER TABLE foo MODIFY COLUMN Hobby VARCHAR(20) FIRST;

I don't know whether or not there's a GUI way to do it in phpmyadmin, but normal SQL queries should work, too.

我不知道在phpmyadmin中是否有GUI方式来执行,但是普通的SQL查询也应该有效。

#2


43  

phpMyAdmin has finally included this feature in the most recent version (4.0 and up).

phpMyAdmin终于在最近的版本(4.0和up)中加入了这个特性。

Go to the "Structure" view for a table, click the Change button on the appropriate field, then under "Move column" select where you would like the field to go.

转到表的“结构”视图,单击相应字段上的Change按钮,然后在“Move column”下选择您希望该字段的位置。

#3


21  

To reorder columns, pop-up a query window and use the statement:

若要重新排序列,请弹出查询窗口并使用语句:

ALTER TABLE ... MODIFY COLUMN ... FIRST|AFTER ...

Unfortunately you will have to retype the entire column definition. See http://dev.mysql.com/doc/refman/5.1/en/alter-table.html Example:

不幸的是,您将不得不重新键入整个列定义。见http://dev.mysql.com/doc/refman/5.1/en/alter-table.html的例子:

ALTER TABLE t MODIFY COLUMN cherry VARCHAR(255) NULL AFTER banana;

May vary depending on your MySQL version, but this syntax appears to work since version 3.23.

根据您的MySQL版本可能会有所不同,但是这个语法从3.23版本开始就可以使用了。

#4


16  

The ever changing answer!

不断变化的答案!

No "Change" button any more but now a "Move columns" button.

没有“更改”按钮,但现在是“移动列”按钮。

Works fine. (IE click on "Structure" tab and click on "Move columns" and voila!)

工作很好。(点击“结构”选项卡,点击“移动栏目”,瞧!)

使用phpadmin重新排列列的顺序

#5


6  

Unfortunately, you will have to (1) pop up a query window, and (2) respecify the attributes of each column you rearrange. For example:

不幸的是,您将不得不(1)弹出一个查询窗口,(2)重新指定重新排列的每个列的属性。例如:

ALTER TABLE test.`new table`
  MODIFY COLUMN cherry unsigned int(10) NOT NULL AUTOINCREMENT PRIMARY KEY 
  AFTER banana

Table layout before change:

表布局之前改变:

`apple`  varchar(45) NOT NULL,
`cherry` int(10) unsigned NOT NULL AUTO_INCREMENT,
`banana` varchar(45) NOT NULL

Table layout after change:

表布局后的改变:

`apple`  varchar(45) NOT NULL,
`banana` varchar(45) NOT NULL,
`cherry` int(10) unsigned NOT NULL AUTO_INCREMENT

#1


40  

Use the ALTER TABLE with MODIFY COLUMN command. Something like:

使用带有修改列命令的ALTER TABLE。喜欢的东西:

ALTER TABLE foo MODIFY COLUMN Hobby VARCHAR(20) FIRST;

I don't know whether or not there's a GUI way to do it in phpmyadmin, but normal SQL queries should work, too.

我不知道在phpmyadmin中是否有GUI方式来执行,但是普通的SQL查询也应该有效。

#2


43  

phpMyAdmin has finally included this feature in the most recent version (4.0 and up).

phpMyAdmin终于在最近的版本(4.0和up)中加入了这个特性。

Go to the "Structure" view for a table, click the Change button on the appropriate field, then under "Move column" select where you would like the field to go.

转到表的“结构”视图,单击相应字段上的Change按钮,然后在“Move column”下选择您希望该字段的位置。

#3


21  

To reorder columns, pop-up a query window and use the statement:

若要重新排序列,请弹出查询窗口并使用语句:

ALTER TABLE ... MODIFY COLUMN ... FIRST|AFTER ...

Unfortunately you will have to retype the entire column definition. See http://dev.mysql.com/doc/refman/5.1/en/alter-table.html Example:

不幸的是,您将不得不重新键入整个列定义。见http://dev.mysql.com/doc/refman/5.1/en/alter-table.html的例子:

ALTER TABLE t MODIFY COLUMN cherry VARCHAR(255) NULL AFTER banana;

May vary depending on your MySQL version, but this syntax appears to work since version 3.23.

根据您的MySQL版本可能会有所不同,但是这个语法从3.23版本开始就可以使用了。

#4


16  

The ever changing answer!

不断变化的答案!

No "Change" button any more but now a "Move columns" button.

没有“更改”按钮,但现在是“移动列”按钮。

Works fine. (IE click on "Structure" tab and click on "Move columns" and voila!)

工作很好。(点击“结构”选项卡,点击“移动栏目”,瞧!)

使用phpadmin重新排列列的顺序

#5


6  

Unfortunately, you will have to (1) pop up a query window, and (2) respecify the attributes of each column you rearrange. For example:

不幸的是,您将不得不(1)弹出一个查询窗口,(2)重新指定重新排列的每个列的属性。例如:

ALTER TABLE test.`new table`
  MODIFY COLUMN cherry unsigned int(10) NOT NULL AUTOINCREMENT PRIMARY KEY 
  AFTER banana

Table layout before change:

表布局之前改变:

`apple`  varchar(45) NOT NULL,
`cherry` int(10) unsigned NOT NULL AUTO_INCREMENT,
`banana` varchar(45) NOT NULL

Table layout after change:

表布局后的改变:

`apple`  varchar(45) NOT NULL,
`banana` varchar(45) NOT NULL,
`cherry` int(10) unsigned NOT NULL AUTO_INCREMENT