Re: how to show foreign keys of a table

From: "Dominic J(dot) Eidson" <sauron(at)the-infinite(dot)org>
To: "T(dot) Dekany" <linux_ch(at)scientist(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to show foreign keys of a table
Date: 2000-12-30 04:06:14
Message-ID: Pine.LNX.4.21.0012292204520.11429-100000@morannon.the-infinite.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 26 Dec 2000, T. Dekany wrote:

> Hi,
> in psql, the command "\d <table>" gives me the table-definitions, but
> the defined foreign keys don't show up. How can I get those? How can I
> check, what foreign keys a table has?
> Thanx

This was posted to the list a while ago, compliments of Michael Fork
<mfork(at)toledolink(dot)com>:

SELECT pt.tgargs, pt.tgnargs, pt.tgdeferrable, pt.tginitdeferred,
pg_proc.proname, pg_proc_1.proname FROM pg_class pc,
pg_proc pg_proc, pg_proc pg_proc_1, pg_trigger pg_trigger,
pg_trigger pg_trigger_1, pg_proc pp, pg_trigger pt
WHERE pt.tgrelid = pc.oid AND pp.oid = pt.tgfoid
AND pg_trigger.tgconstrrelid = pc.oid
AND pg_proc.oid = pg_trigger.tgfoid
AND pg_trigger_1.tgfoid = pg_proc_1.oid
AND pg_trigger_1.tgconstrrelid = pc.oid
AND ((pc.relname= '<< TABLENAME >>>')
AND (pp.proname LIKE '%%ins')
AND (pg_proc.proname LIKE '%%upd')
AND (pg_proc_1.proname LIKE '%%del')
AND (pg_trigger.tgrelid=pt.tgconstrrelid)
AND (pg_trigger_1.tgrelid = pt.tgconstrrelid));

--
Dominic J. Eidson
"Baruk Khazad! Khazad ai-menu!" - Gimli
-------------------------------------------------------------------------------
http://www.the-infinite.org/ http://www.the-infinite.org/~dominic/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Mascari 2000-12-30 04:14:14 Re: Re: Failed Statements within Transactions
Previous Message Matt A. Zinicola 2000-12-30 03:44:19 Re: PowerDesigner support?