Re: Querying a parent table's child schemas

Поиск
Список
Период
Сортировка
От Matthews, James
Тема Re: Querying a parent table's child schemas
Дата
Msg-id 067C9A1F6AFEB643895EA4513E116884BB5427@exfp1.Railpowertech.local
обсуждение исходный текст
Ответ на Re: Querying a parent table's child schemas  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Querying a parent table's child schemas  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
In my database there is the public schema (default) with the parent
alarms table.  Each 'customer' has their own schema via CREATE SCHEMA,
and then each schema has an alarms table (CREATE TABLE alarm INHERITS
public.alarms).  While the tabloid column seems like it should work when
I do the following:

SELECT a.date, a.log_msg, p.relname
FROM alarms a, pg_class p
WHERE a.tableoid = p.oid;

The relname column just lists alarms for every row.  I'm looking to find
the schema name, not the table name.  Is it a little clearer now?
Regardless thank you for your reply as I believe that it is a step in
the right direction!  Any further advice would be appreciated.

Respectfully,

James L. Matthews, III

-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Tom Lane
Sent: Thursday, August 30, 2007 12:01 PM
To: Matthews, James
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Querying a parent table's child schemas

"Matthews, James" <jmatthews@Railpower.com> writes:
>       I was wondering if there was a way to SELECT from a parent table
> and display the schema associated with a child table's data.

It's not entirely clear to me which meaning of "schema" you have in
mind, but perhaps the tableoid system column would help you?  That
lets you determine which child table the row really came from,
and then you can join to the system catalogs to get whatever data
you are actually after.

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

В списке pgsql-novice по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Could not remove file messages
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Querying a parent table's child schemas