2

under AWS Redshift

I created a temp table with

select all 
*
into temp table #cleaned_fact
from fact_table
limit 100

get

Executed successfully

Updated 0 rows in 0.716 seconds.

and try to check the data in temp table with

select *
from #cleaned_fact

get error

ERROR: relation "#cleaned_fact" does not exist

======================================================= update 1.

be careful

The temp table exists only for duration of your session using which you have created the table.

    create temp table IF NOT EXISTS #cleaned_fact
(
col1 INT NOT NULL encode delta,
col2 INT NOT NULL encode mostly16,
col3 INT NOT NULL encode runlength,
col4 BIGINT NOT NULL encode mostly32,
);
insert into #cleaned_fact
select *
from fact_channel_posting
limit 100

returns

Executed successfully

Updated 100 rows in 3.101 seconds.

but in another session select * from #cleaned_fact still returns the same error

2 Answers 2

1

Try in this way to create temp table

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
[(create_definition,...)]
[table_options]
select_statement



CREATE TEMPORARY TABLE IF NOT EXISTS mytable
(id int(11) NOT NULL, PRIMARY KEY (id)) ENGINE=MyISAM;
INSERT IGNORE INTO mytable SELECT id FROM table WHERE xyz;
Sign up to request clarification or add additional context in comments.

1 Comment

thx for the response. tried still the same error by selecting from temp table
1

The strategy in update 1 succeeded. The problem was:

The temp table exists only for duration of your session using which you have created the table.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.