Re: Which schema I am woking on??

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Harry Yau <harry(at)aurasound(dot)com(dot)hk>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Which schema I am woking on??
Date: 2003-07-12 04:50:25
Message-ID: 20030712045024.GA16646@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 11, 2003 at 10:45:57AM +0800, Harry Yau wrote:

> Firstly, is there anyway to find out which Schema I am working on, so I
> could query the pg_tables with a specified schemaname??
> I have tried to select current_schema. However, it always return
> "public" to me.

Actually, the temp schema is always empty for a new session. I think
you can use something like this to detect if a table exists in the
current temp schema:

select * from pg_class
where relname='foo' and
relnamespace=(
select oid
from pg_namespace
where nspname = (
select 'pg_temp_'|| foo
from pg_stat_get_backend_idset() as foo
where pg_stat_get_backend_pid(foo)=pg_backend_pid()
)
);

> Second, I am wondering how could I drop the automically created schema
> automically? Could I config the system to make it drop the correpsonding
> schema whenever a session is terminated?

You don't need to, it already does that.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Si quieres ser creativo, aprende el arte de perder el tiempo"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Seichter 2003-07-12 08:05:12 Re: What about a comp.databases.postgresql usenet newsgroup
Previous Message Jeffrey Melloy 2003-07-12 03:24:11 Re: Am I using the SERIAL type properly?