

MYSQL CHANGE COLUMN UPDATE
To remove a table in MySQL, use the DROP TABLE statement. First, create the new column with type data Next, run update query, to populate the new column with the value of the old one, applying any conversion if needed Next, drop the old column Finally, rename the new column to the old one.

The advantage to doing it yourself is that you can do the schema change and the initial population while your database is live, and then lock the original before you do a final update for any data that may have changed in the meantime and then the final swap-it-into-place. If the column has any null values, you need to first update all the null values to non-null. Run INSERT INTO new_table (SELECT * FROM old_table) - note that you'll need to in fact be explicit with columns at least for the INSERT, and I recommend for the SELECT as well (that way you'll have a pattern you can follow when re-ordering columns as well).

Internally MySQL creates a new table with the desired structure, copies all your data over to that, and then finally swaps datafiles to effect a drop of the original table with a "rename" of the new.
