Skip site navigation (1) Skip section navigation (2)

Querying a parent table's child schemas

From: "Matthews, James" <jmatthews(at)Railpower(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Querying a parent table's child schemas
Date: 2007-08-30 13:30:56
Message-ID: 067C9A1F6AFEB643895EA4513E116884BB53ED@exfp1.Railpowertech.local (view raw or flat)
Thread:
Lists: pgsql-novice
Greetings all,

      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.  There's
the general idea now let me explain further...  I have a parent table
called alarms, whenever a new user uploads any alarms to the database a
schema is created which inherits the attributes of the public alarms
table (the different schemas allow me to keep track of who uploaded
what).  In this way, I am able to look through all the alarms by
querying public.alarms as well as query each individual schema's alarms
table.  What I want to do however, is let's say perform a query like: 

 

SELECT date, time, alarm_code, alarm_msg, child_schema() FROM
public.alarms;

 

I know there is a command current_schema(), but when querying the
public.alarms table I only get the public schema, and not the schema of
the associated children tables.

 

Does anybody know if this is even possible?  If so any information or
tips would be greatly appreciated.

 

Thanks in advance,

 

James L. Matthews

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2007-08-30 16:01:14
Subject: Re: Querying a parent table's child schemas
Previous:From: Michael GlaesemannDate: 2007-08-29 19:58:05
Subject: Re: using system catalogs

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group