Обсуждение: Find out foreign key

Поиск
Список
Период
Сортировка

Find out foreign key

От
Alexander Burbello
Дата:
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.

Re: Find out foreign key

От
Chris Mair
Дата:
> 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