简体   繁体   中英

Insert Statement - From Temp Table

I am currently trying to insert data into a Redshift table from multiple temporary tables that I have created.

Insert into schema.table1 (

with a as (
select t1.country_code, t1.country_name
from t1
)

select * from a
);

The error that I get on this statement says the following: Amazon Invalid operation: syntax error at or near "as";. What do I need to change in order to be able to insert data from a temp table?

Is it not possible to run the command like this if you have same table structures in both schema.table1 and t1

insert into schema.table1 
select t1.country_code, t1.country_name
from t1;

One other thing you might want to check is, in your SQL table1 is in 'schema' but t1 is referred without a schema so it's in public, make sure you don't have two t1s with different structures.

I just tried this and it worked for me.

insert into tempt1 ( with a as (select a from tempt2) select * from a);

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