Re: inherited type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Miguel Angel Tribaldos Hervas <mitriher(at)teleco(dot)upv(dot)es>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: inherited type
Date: 2005-04-01 15:30:04
Message-ID: 6596.1112369404@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Miguel Angel Tribaldos Hervas <mitriher(at)teleco(dot)upv(dot)es> writes:
> I am working with inheritance in postgresql 7.4. If I create a table named A,
> and another named B that inherits from A, if I perform a query such a
> "SELECT * FROM A" (without ONLY clause),
> how can I get the type (identifier from pg_type) of the returned records??

I think what you are after is the "tableoid" system column. Try
SELECT tableoid, * FROM A;
or more readably
SELECT tableoid::regclass, * FROM A;
or you can do the above "by hand"
SELECT p.relname, A.* FROM A, pg_class p WHERE p.oid = a.tableoid;

If you really want the composite type IDs then it's
SELECT p.reltype, A.* FROM A, pg_class p WHERE p.oid = a.tableoid;

regards, tom lane

In response to

  • inherited type at 2005-04-01 10:42:19 from Miguel Angel Tribaldos Hervas

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-04-01 15:42:16 Re: inherited type
Previous Message Tom Lane 2005-04-01 15:03:50 Re: PL/PERL with composite return values & PGSQL 7.4?