简体   繁体   中英

How to rename multiple columns of a table in Snowflake?

I have a table, say table1 and it has three columns ( col1_a, col2_b, col3_c ). I want to rename the columns to col1, col2, col3 . But the thing is I want to rename all columns in a single query.

Is there a way to achieve this?

You can use a select :

select col1_a as col1, col2_a as col2, col3_a as col3
from t;

If you want to actually change the names in the table, I think you need three alter tables:

alter table t rename column col1_a to col1;
alter table t rename column col2_a to col2;
alter table t rename column col3_a to col3;

I don't think Snowflake allows multiple renames with a single alter table .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM