insert into temp
select code,
case when code = 'S' then 1
when code = 'U' then 0
when code = 'R' then 4
end
from "table" r
临时表错误-如何在雪花中创建临时表而不必注意每一列
答案 0 :(得分:1)
Create temp table temp as
select code,
case when code = 'S' then 1
when code = 'U' then 0
when code = 'R' then 4
end
from "table" r;
答案 1 :(得分:0)
您只需要指定与选择语句中的列列表相匹配的目标临时表的列即可。
是的,您必须指定所有列名,包括数据类型。
create table "table" ( code varchar);
insert into "table" values ('S');
insert into "table" values ('U');
insert into "table" values ('R');
select code,
case when code = 'S' then 1
when code = 'U' then 0
when code = 'R' then 4
end
from "table" r;
Create temp table temp as
select code,
case when code = 'S' then 1
when code = 'U' then 0
when code = 'R' then 4
end
from "table" r; --SQL compilation error: Missing column specification
Create temp table temp (code varchar, code_no int) as
select code,
case when code = 'S' then 1
when code = 'U' then 0
when code = 'R' then 4
end as code_no
from "table" r;
select * from temp;
文档参考:https://docs.snowflake.com/en/sql-reference/sql/insert.html#optional-parameters