Referencing a global temp with same name as local temp table

Moderator: NorbertKrupa

Post Reply
User avatar
Josh
Intermediate
Intermediate
Posts: 106
Joined: Thu Jan 26, 2012 9:38 pm

Referencing a global temp with same name as local temp table

Post by Josh » Tue Nov 04, 2014 4:39 pm

Hello,

If I create a global and local temp with the same name, when I query the table name I get the local temp table.

Code: Select all

dbadmin=> create global temp table temp_table (g_a int);
CREATE TABLE
dbadmin=> create local temp table temp_table (l_a int);
CREATE TABLE
dbadmin=> select * from temp_table;
 l_a
-----
(0 rows)
So how can I reference the global temp table?
Thank you!
Joshua

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Referencing a global temp with same name as local temp t

Post by JimKnicely » Tue Nov 04, 2014 5:42 pm

Hi,

You can specify a schema for for a global temp table but not a local temp table. Locale temp tables are always created in the v_temp_schema schema.

If you do not specify a schema name for the global temp table it will be created in the default schema in your search path. Most likely the public schema.

Try checking v_catalog.tables for the schema names of your temp tables:

select table_schema from tables where table_name = 'temp_table';
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

User avatar
Josh
Intermediate
Intermediate
Posts: 106
Joined: Thu Jan 26, 2012 9:38 pm

Re: Referencing a global temp with same name as local temp t

Post by Josh » Fri Nov 07, 2014 7:54 pm

Great explanation, Jim! Thanks for your help :D
Thank you!
Joshua

Post Reply

Return to “New to Vertica Database Administration”