Alter multiple columns in a single statement

MysqlSqlMysql Error-1064Alter Table

Mysql Problem Overview


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.

Mysql Solutions


Solution 1 - Mysql

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),
    ...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSangram AnandView Question on Stackoverflow
Solution 1 - MysqlAndomarView Answer on Stackoverflow