简体   繁体   English

如何通过 mysql 工作台更改列顺序?

[英]How can I change column order through mysql workbench?

I know how to reorder column order through query, How do I reorder columns in MySQL Query Editor?我知道如何通过查询重新排序列顺序, 如何在 MySQL 查询编辑器中重新排序列? , ,

I just want to know is there any other (simpler) way to do this directly through MySQL workbench.我只想知道是否有任何其他(更简单)的方法可以直接通过 MySQL 工作台执行此操作。

Right-click the column and choose Move Up or Move Down .右键单击该列并选择上Move UpMove Down Dragging does not work in MySQL Workbench 6.3.拖动在 MySQL Workbench 6.3 中不起作用。

在此处输入图片说明

P.Salmon commented with a link that has more detail. P.Salmon 评论了一个包含更多细节的链接

  • Open Alter Table打开更改表
  • Just move column with your mouse to the position you want (Do not select it before this action)只需用鼠标将列移动到您想要的位置(在此操作之前不要选择它)

First of all you should get column definition by using show create Table then I think Modify should work首先,您应该使用show create Table获得列定义,然后我认为Modify应该可以工作

ALTER TABLE yourTableName MODIFY bar bartype AFTER baz;

Hope it will help希望它会有所帮助

As the previous answers point out, we need open Alter Table first.正如前面的答案所指出的,我们需要先打开 Alter Table。 On workbench 8.0, right click table, then click 'Alter table'在工作台 8.0 上,右键单击表,然后单击“更改表”

Image to show how to open Alter Table on Workbench 8.0显示如何在 Workbench 8.0 上打开 Alter Table 的图像

The SQL I got from moving a column is as follows with "CHANGE COLUMN" keywords.我从移动列中得到的 SQL 如下,带有“CHANGE COLUMN”关键字。

ALTER TABLE `your_database`.`your_table` 
CHANGE COLUMN `column_a` `column_a` VARCHAR(16) NULL DEFAULT NULL COMMENT 'this is comment' AFTER `colum_b`;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM