Tag Archives: table

Change column position in mysql table

Many times, we come across the situation where a column needs to be re-position in the table. Either at first position, at last position or  anywhere in the table after some columns. This particular modification can be done using ALTER TABLE queries.

#Position a column at first position
ALTER TABLE table_name MODIFY COLUMN column_name datatype FIRST;
Example : ALTER TABLE events MODIFY COLUMN event_id INT FIRST;
#Position a column after specific column
ALTER TABLE table_name MODIFY COLUMN column_name datatype AFTER another_column;
Example : ALTER TABLE events MODIFY COLUMN event_id INT AFTER event_name;