You Are Here Home > How to move a column’s position in a MySQL table

How to move a column’s position in a MySQL table

You can move a column in a MySQL table to another position like this:

ALTER TABLE name_of_the_table MODIFY column_to_move tinyint(1) DEFAULT '0' AFTER column_to_move_after

Note: the part with: “tinyint(1) default ‘0′” is necessary and it should be the exact definition of your column.
For example yours might be:
int(10) unsigned NOT NULL auto_increment
or
int(10) unsigned NULL default ‘0′
or

How to move a column’s position in a MySQL table
Filed under: MySQL, Web Development   Posted by: Codehead

Got a Question?

Get answers here.

2 Comments »

  1. Anonymous:
     

    …but how does one move a column to the TOP of the table? So it is the first column?

    Comment

  2. Codehead:
     

    Here it is:
    http://codingrecipes.com/database-servers/mysql-rearrange-move-mysql-table-columns

    Comment

RSS feed for comments on this post. TrackBack URL

Leave a comment