Re: Finding if a temp table exists in the current connection

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org, m(dot)papper(at)fantastic(dot)com
Subject: Re: Finding if a temp table exists in the current connection
Date: 2003-04-04 14:58:24
Message-ID: 5648.1049468304@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Christoph Haller <ch(at)rodos(dot)fzk(dot)de> writes:
> It looks like they are created in name spaces called "pg_temp_<N>,
> where N is simply a connection counter.

Right. If you are trying to find out which N applies to your session,
here is one way:

regression=# select current_schemas(true);
current_schemas
---------------------
{pg_catalog,public}
(1 row)

regression=# create temp table z(f1 int);
CREATE TABLE
regression=# select current_schemas(true);
current_schemas
-------------------------------
{pg_temp_2,pg_catalog,public}
(1 row)

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-04-04 16:16:01 Re: can i make this sql query more efficiant?
Previous Message Christoph Haller 2003-04-04 11:16:16 Re: Finding if a temp table exists in the current connection