pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Determining Inheritance
2+ messages / 2 participants
[nested] [flat]

* Determining Inheritance
@ 2003-10-01 09:51 Gordon Ross <G.Ross@ccw.gov.uk>
  2003-10-01 14:26 ` Re: Determining Inheritance Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Gordon Ross @ 2003-10-01 09:51 UTC (permalink / raw)
  To: pgsql-sql

Is there any way to determine which table a row belows to, if I do a
search on the top level table:

e.g. I have a table called "BASE". There are two tables which inherit
from "BASE" called "SUBTABLE1" and "SUBTABLE2"

If I do a SELECT * FROM BASE WHERE blah; how can I tell which table
(either SUBTABLE1 or SUBTABLE2) a row comes from ?

Do I need to add an extra column to BASE to specify which table a row
really belongs to ?

(If it helps or hinders, I am ultimately going to be doing this via
JDBC)

Thanks,

GTG

Gordon Ross,
Network Manager/Rheolwr Rhydwaith
Countryside Council for Wales/Cyngor Cefn Gwlad Cymru



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Determining Inheritance
  2003-10-01 09:51 Determining Inheritance Gordon Ross <G.Ross@ccw.gov.uk>
@ 2003-10-01 14:26 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2003-10-01 14:26 UTC (permalink / raw)
  To: Gordon Ross <G.Ross@ccw.gov.uk>; +Cc: pgsql-sql

"Gordon Ross" <G.Ross@ccw.gov.uk> writes:
> Is there any way to determine which table a row belows to, if I do a
> search on the top level table:

Look at the built-in column "tableoid".  You can join this to
pg_class.oid to retrieve the table name.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-10-01 14:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-01 09:51 Determining Inheritance Gordon Ross <G.Ross@ccw.gov.uk>
2003-10-01 14:26 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox