Reputation: 93
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 ?
Upvotes: 3
Views: 11107
Reputation: 1269883
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
.
Upvotes: 6