Re: INHERIT

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: Peter Harvey <pharvey(at)codebydesign(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INHERIT
Date: 2001-09-09 19:16:00
Message-ID: 200109091916.f89JG18s025520@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Harvey wrote:
>If I try to get the columns from pg_attribute using the oid of a child
>table created with INHERIT I get its columns AND all of its inherited
>columns.
>
>How do I just get the columns added by the child table?
>
>I figure I could check each column to see if they also exist in
>pg_attribute under a parent table but I figure there must be an
>easier/faster way? Another pg_* table perhaps? Besides; I am not certian
>this would work if there is a common column between a child and one of
>its parents (if that is even allowed)?
>
>As usual, any help would be greatly appreciated.

SELECT a.attname
FROM pg_attribute AS a,
pg_class AS c,
pg_inherits AS i
WHERE a.attrelid = c.oid AND
i.inhrelid = c.oid AND
c.relname = 'child_table'
AND a.attname NOT IN (
SELECT a.attname
FROM pg_attribute AS a,
pg_class AS c,
pg_inherits AS i
WHERE i.inhrelid = c.oid AND
a.attrelid = i.inhparent AND
c.relname = 'child_table'
)

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Submit yourselves therefore to God. Resist the devil,
and he will flee from you." James 4:7

Responses

  • Re: INHERIT at 2001-09-09 18:23:57 from Hannu Krosing

Browse pgsql-hackers by date

  From Date Subject
Next Message Barry Lind 2001-09-09 19:51:10 Re: [HACKERS] Troubles using German Umlauts with JDBC
Previous Message Rene Pijlman 2001-09-09 18:28:15 Timezones and time/timestamp values in FE/BE protocol