Re: Temporary schemas

From: Thom Brown <thom(at)linux(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Temporary schemas
Date: 2010-11-01 11:33:44
Message-ID: AANLkTimgiDKAFat-gLVwJMejzwEuOiekT0UzL1dKUPAL@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1 November 2010 10:46, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:

> Hello,
>
> I have created a temporary table using
>
> create temporary table foo
> (
> id integer
> );
>
> and noticed this was created in a schema called "pg_temp_2"
>
> My question is:
>
> is this always "pg_temp_2"?
> Or will the name of the "temp schema" change?
>
> If it isn't always the same, is there a way I can retrieve the schema name
> for temporary tables?
>
> Regards
> Thomas
>
>
You can use:

SELECT nspname
FROM pg_namespace
WHERE oid = pg_my_temp_schema();

to get the name of the current temporary schema for your session.

And it's always pg_temp_[nnn] as far as I'm aware, with a corresponding
pg_toast_temp_[nnn] schema.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2010-11-01 11:38:48 Re: Temporary schemas
Previous Message Fujii Masao 2010-11-01 11:00:22 Re: Failover on Windows