How can I change the position of a certain existing column in MySQL table?
Ex: I want to move the column username from its current position to
ALTER TABLE [tbl_name] MODIFY|CHANGE [column definition] [AFTER|BEFORE] [a_column]
both would work. MODIFY
would be preferable if you only want to change column order but not renaming. Also, you CANNOT combine multiple columns reordering in a single ALTER TABLE statement. I.E. to rearrange integer columns col1, col2, col3 order to be in the order of col3, col2, col1, you will have to do
ALTER TABLE tbl_name MODIFY col3 int FIRST;
ALTER TABLE tbl_name MODIFY col2 int AFTER col3;