Move a Column in MySQL
Every now and again I’ll go into clean up mode and start cleaning up my database tables. One of the things I like to do is put my columns in some kind of a logical order. I can never remember the command for doing so. As a result I’m leaving a little reminder as to how to rearrange the columns in a MySQL DB table.
Assuming I have a table called users, the columns id and username and I want username to immediately follow id.
ALTER TABLE `users` MODIFY COLUMN username varchar(20) AFTER id;