finding foreign keys

From: Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: finding foreign keys
Date: 2001-01-23 21:50:25
Message-ID: 3A6DFCA1.248D0979@yellowbank.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Can anyone suggest a more elegant way of finding foreign keys than
parsing the tgargs value returned by this query? I'd really rather do
pure SQL, sans string parsing, if possible.

------------------------------------------------------------------------
-- Find tables and foreign keys

CREATE VIEW foreignkeysa AS
SELECT t.oid as toid,
c1.relname AS relid,
c2.relname AS constrrelid,
t.tgargs AS tgargs

FROM pg_trigger AS t,
pg_class AS c1,
pg_class AS c2

WHERE t.tgrelid=c1.oid AND
t.tgconstrrelid=c2.oid AND
t.tgfoid=1644;
------------------------------------------------------------------------

-Ron-

Browse pgsql-sql by date

  From Date Subject
Next Message David Wall 2001-01-23 22:16:38 Re: blobs and small binary objects
Previous Message Keith Perry 2001-01-23 20:01:24 Inserting and incrementing with MAX aggregate