Re: viewing foreign key constraints

Поиск
Список
Период
Сортировка
От GH
Тема Re: viewing foreign key constraints
Дата
Msg-id 20010117184405.A91720@over-yonder.net
обсуждение исходный текст
Ответ на Re: viewing foreign key constraints  (Michael Fork <mfork@toledolink.com>)
Список 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
> >
>

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Errors compiling 7.0.3 on Solaris 7
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] RE: Help with query. (*)