Re: Temp table visibility

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: JJ <johnjohnson(at)thewildstoat(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
Subject: Re: Temp table visibility
Date: 2011-08-05 14:55:08
Message-ID: 2266.1312556108@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> On Fri, Aug 05, 2011 at 08:35:37AM -0400, JJ wrote:
>> I was recently looking at the way "create temp table as" works and the manual specifies that temp tables given the same name as an existing table will be used instead of the permanent table. It also states that the permanent table can be accessed via its schema-qualified name. I may have answered my own question but is there any way to emulate this table visibility functionality when referencing tables by their schema-qualified name?

> No, because the schema qualification is what makes for the visibility
> functionality.

Also, you can change the priority if you have a mind to, by adding
"pg_temp" to the search_path explicitly, for example

SET search_path = public, pg_temp;

If there's no explicit reference to pg_temp in search_path then it's
implicitly searched first, which is why unqualified references to temp
table names work the way the manual says.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-08-05 15:16:56 Re: Select count with offset returns nothing.
Previous Message Igor Neyman 2011-08-05 14:32:19 Re: Postgresql problem with update double precision