Обсуждение: Determining Inheritance

Поиск
Список
Период
Сортировка

Determining Inheritance

От
"Gordon Ross"
Дата:
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


Re: Determining Inheritance

От
Tom Lane
Дата:
"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