| From: | GH <grasshacker(at)over-yonder(dot)net> |
|---|---|
| To: | Michael Fork <mfork(at)toledolink(dot)com> |
| Cc: | Matt Friedman <matt(at)sprynewmedia(dot)com>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: viewing foreign key constraints |
| Date: | 2001-01-18 00:44:05 |
| Message-ID: | 20010117184405.A91720@over-yonder.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, Jan 17, 2001 at 06:51:00PM -0500, some SMTP stream spewed forth:
> Here is an SQL query that I posted to the list some time ago (its in the
> list archives...)
This seems to come up frequently, but I have not seen any mention of
it in the docs. Is this query in the docs somewhere?
If not, what can I do to put it their? (That is, if putting it in the
docs is acceptable.)
gh
>
> Michael Fork - CCNA - MCP - A+
> Network Support - Toledo Internet Access - Toledo Ohio
>
> Here's the query that, given the primary key table, lists all foreign
> keys, their tables, the RI type, and defereability.
>
> SELECT pg_trigger.tgargs,
> pg_trigger.tgnargs,
> pg_trigger.tgdeferrable,
> pg_trigger.tginitdeferred,
> pg_proc.proname,
> pg_proc_1.proname
> FROM pg_class pg_class,
> pg_class pg_class_1,
> pg_class pg_class_2,
> pg_proc pg_proc,
> pg_proc pg_proc_1,
> pg_trigger pg_trigger,
> pg_trigger pg_trigger_1,
> pg_trigger pg_trigger_2
> WHERE pg_trigger.tgconstrrelid = pg_class.oid
> AND pg_trigger.tgrelid = pg_class_1.oid
> AND pg_trigger_1.tgfoid = pg_proc_1.oid
> AND pg_trigger_1.tgconstrrelid = pg_class_1.oid
> AND pg_trigger_2.tgconstrrelid = pg_class_2.oid
> AND pg_trigger_2.tgfoid = pg_proc.oid
> AND pg_class_2.oid = pg_trigger.tgrelid
> AND ((pg_class.relname='<<PRIMARY KEY TABLE>>')
> AND (pg_proc.proname Like '%upd')
> AND (pg_proc_1.proname Like '%del')
> AND (pg_trigger_1.tgrelid=pg_trigger.tgconstrrelid)
> AND (pg_trigger_2.tgrelid = pg_trigger.tgconstrrelid))
>
>
> On Wed, 17 Jan 2001, Matt Friedman wrote:
>
> > How do I get a list of the foreign key constraints for a table?
> >
> > Matt Friedman
> >
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adam Haberlach | 2001-01-18 01:06:01 | More plpgsql fun! (deleting large object refs) |
| Previous Message | Tom Lane | 2001-01-18 00:37:55 | Re: Errors compiling 7.0.3 on Solaris 7 |