Easy way to re-order columns?

后端 未结 8 1014
粉色の甜心
粉色の甜心 2020-12-24 06:36

I\'m working on a database. On most of the tables, the column order is not what I would expect, and I would like to change it (I have the permission). For example, the prima

8条回答
  •  抹茶落季
    2020-12-24 07:27

    Here is the sql query
    ALTER TABLE table_name MODIFY COLUMN misplaced_column Column-definition AFTER other_column; Here in Column-definition is full column definition. To see the column definition if you are using phpmyadmin click on structure tab. Then click on change link on desired column. Then withour modifyig any things click save. It will show you the sql. Copy the sql and just add *AFTER other_column* at the end. It will be all.

    If you like to bring the *misplaced_column* to the first position then ALTER TABLE table_name MODIFY COLUMN misplaced_column Column-definition FIRST;

提交回复
热议问题