Re: Finding if a temp table exists in the current connection - Mailing list pgsql-sql

From Tom Lane
Subject Re: Finding if a temp table exists in the current connection
Date
Msg-id 5648.1049468304@sss.pgh.pa.us
Whole thread Raw
In response to Re: Finding if a temp table exists in the current connection  (Christoph Haller <ch@rodos.fzk.de>)
List pgsql-sql
Christoph Haller <ch@rodos.fzk.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



pgsql-sql by date:

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