MySQL: Defining column order
To create [column_name] as the first one on [table_name]:
ALTER TABLE table_name ADD COLUMN column_name INT NULL FIRST;
To create the [columnY] right next [columnX] on [table_name]:
ALTER TABLE table_name ADD COLUMN columnY INT NULL AFTER columnX;
To just change the position of [columnX] (obviously, keeping the data):
ALTER TABLE table_name MODIFY COLUMN columnX INT NULL FIRST;
or
ALTER TABLE table_name MODIFY COLUMN columnX INT NULL AFTER columnX;
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#