Re: Find out foreign key

Поиск
Список
Период
Сортировка
От Chris Mair
Тема Re: Find out foreign key
Дата
Msg-id 1155236961.5893.43.camel@dell.home.lan
обсуждение исходный текст
Ответ на Find out foreign key  (Alexander Burbello <alexander@cresoltec.com.br>)
Список pgsql-admin
> Hi people,
>
> I would like to know what's the system view that has information about
> parent table and child table associated by Foreign Key!!
>
> Is it possible to find out that information?
>
> Thank you.

Here you go (tested on 8.1) :)

SELECT c.relname as table, r.conname as contraint,
pg_catalog.pg_get_constraintdef(r.oid, true) as constraint_definition
FROM pg_catalog.pg_constraint r, pg_catalog.pg_class c WHERE c.oid =
r.conrelid AND r.contype = 'f';

Bye,
Chris.


--

Chris Mair
http://www.1006.org



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

Предыдущее
От: Steve Crawford
Дата:
Сообщение: Re: pg_dump from crontab
Следующее
От: Tom Lane
Дата:
Сообщение: Re: data for 64bits on 32