在单个语句中更改多个列 [英] Alter multiple columns in a single statement

查看:70
本文介绍了在单个语句中更改多个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用查询来更改列的字符集

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

我想对其他列main_title,landing_page_body也这样做.但是执行时出现#1064错误.我可以在一个查询中更改多个列吗?

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?

我尝试过,但在goog搜索中发现它不可能在单个查询中更改.

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

推荐答案

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

这篇关于在单个语句中更改多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆