Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B3CED632FB7 for ; Wed, 6 May 2009 16:24:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 24550-04 for ; Wed, 6 May 2009 16:24:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by mail.postgresql.org (Postfix) with ESMTP id D00D4632C85 for ; Wed, 6 May 2009 16:24:09 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-118-67.bk8-dsl.surnet.cl [200.126.118.67]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id n46JVTu5017837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 6 May 2009 12:31:31 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 2C284D4179; Wed, 6 May 2009 15:23:54 -0400 (CLT) Date: Wed, 6 May 2009 15:23:54 -0400 From: Alvaro Herrera To: Robert =?iso-8859-1?Q?Gravsj=F6?= Cc: liuzg4 liuzg4 , pgsql-general@postgresql.org Subject: Re: how to select temp table Message-ID: <20090506192354.GK4476@alvh.no-ip.org> References: <4A01CFE8.9010005@blogg.se> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4A01CFE8.9010005@blogg.se> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Wed, 06 May 2009 12:31:32 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/213 X-Sequence-Number: 147351 Robert Gravsjö escribió: > On 2009-05-06 14.34, liuzg4 liuzg4 wrote: >> ver 8.4 >> i create two table with same name named 'testtable' >> >> one is temp table >> >> i select * from testtable >> then this table is a public or a temp ??? > > Temp. To access public use "select * from public.testtable". > > "Temporary tables exist in a special schema, so a schema name cannot be > given when creating a temporary table." Note that you can refer to the temp table like this: select * from pg_temp.testtable; Also, you can make the non-temp table first in the search path by putting pg_temp later than the public schema (or wherever you have created the function): select * from testtable; -- refers to temp set search_path to 'public', 'pg_temp'; select * from testtable; -- refers to non-temp -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.