Alter multiple columns in a single statement

Sangram Anand picture Sangram Anand · Jun 1, 2012 · Viewed 56.5k times · Source

I am using a query to alter the charset of a column

ALTER TABLE `media_value_report` 
    CHANGE `index_page_body` `index_page_body` TEXT CHARACTER  
    SET utf8 NULL DEFAULT NULL

i want to do this for other columns main_title, landing_page_body as well. But am getting a #1064 error while executing. Can i alter-change multiple columns in a single query?

I tried but i found in goog search that is not possible to alter in a single query.

Answer

Andomar picture Andomar · Jun 1, 2012

The documentation suggests you can chain alter_specifications with a comma:

ALTER TABLE `media_value_report` 
    CHANGE col1_old col1_new varchar(10),
    CHANGE col1_old col1_new varchar(10),
    ...