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 primary_key's id
columns are rarely the first column!
Is there an easy method of moving columns with phpMyAdmin?
On your computer, open a spreadsheet in Google Sheets. Select the rows or columns to move. At the top, click Edit. Select the direction you want to move the row or column, like Move row up.
Using SQL Server Management StudioIn Object Explorer, right-click the table with columns you want to reorder and select Design. Select the box to the left of the column name that you want to reorder. Drag the column to another location within the table.
Use an ALTER TABLE ... MODIFY COLUMN statement.
ALTER TABLE table_name MODIFY COLUMN misplaced_column INT(11) AFTER other_column;
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With