Querying From Temp Table

Database
Enthusiast

Querying From Temp Table

Hi,

 

So I'm still farily new to Teradata, but can someone help explain to me why when I create a temp table, I can't query from it in another (new) SQL editor?

 

For example, say I create the temp table below:

  CREATE VOLATILE TABLE tmp_Table AS
    (
        Select * FROM ...
    ) 
WITH DATA
ON COMMIT PRESERVE ROWS;

When I try to do a simple "SELECT * FROM tmp_Table", in another query editor, it returns the error: Object 'tmp_Table' does not exist.

 

Any ideas as to why?

 

Thanks!


Accepted Solutions
Teradata Employee

Re: Querying From Temp Table

temp tables only exist in the creating session.

 

To use acroos sessions use Global temp tables

 

Dave

1 ACCEPTED SOLUTION
3 REPLIES
Teradata Employee

Re: Querying From Temp Table

temp tables only exist in the creating session.

 

To use acroos sessions use Global temp tables

 

Dave

Enthusiast

Re: Querying From Temp Table

Got it, makes sense.

 

Thanks David!

Teradata Employee

Re: Querying From Temp Table

For GLOBAL TEMPORARY tables, the definition exists within the data dictionary. Multiple sessions can reference that definition, but each will have its own private instance of the temporary table; the contents of an instance will only be available within that one session.

For VOLATILE tables, even the definition exists only within the session that creates the table.

To access the same content from multiple sessions, use a regular, "permanent" table.