简体   繁体   English

如何在 Snowflake 中重命名表的多个列?

[英]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 ).我有一张桌子,比如 table1,它有三列( col1_a、col2_b、col3_c )。 I want to rename the columns to col1, col2, col3 .我想将列重命名为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

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 .我不认为 Snowflake 允许使用单个alter table进行多次重命名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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