Re: knowing which table/schema is going to be chosen

From: Richard Huxton <dev(at)archonet(dot)com>
To: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: knowing which table/schema is going to be chosen
Date: 2009-11-12 10:38:27
Message-ID: 4AFBE5A3.5080706@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ivan Sergio Borgonovo wrote:
> I have a search_path that may not just consist of $user, public.
> eg.
> $user, public, test, import
>
> I'd like to know which table is going to be chosen if I do a
> select * from mytable;

> Is there a way to ask postgresql the schema of the table that will be
> chosen?

Hmm - I don't know of a specific function. You could do something like
this though:

SELECT nspname FROM pg_namespace
WHERE oid = (
SELECT relnamespace FROM pg_class
WHERE oid = 'mytable'::regclass::oid
);

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2009-11-12 10:39:27 Re: DB Restart
Previous Message Richard Huxton 2009-11-12 10:33:22 Re: "duplicate key violates unique constraint" error