Обсуждение: Foreign keys

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

Foreign keys

От
MMM
Дата:
Sorry for my bad English

I'd like to know how I can see the foreign keys for a table.

Is there a system table where I can do a Select?;

Thank you.


Re: Foreign keys

От
Stephan Szabo
Дата:
You can reconstruct the information out of the triggers
that are created in pg_trigger.  It's not easy to
parse however.

There are three triggers created for each fk constraint,
one on the fk table, two on the pk table.  You can
get the tables, columns constrained and match type from
the tgargs.  The referential actions are determined
by the function oids of the pk table triggers (do something
like:
 select pg_proc.proname from pg_trigger,pg_proc where
  pg_trigger.tgfoid=pg_proc.oid;
to get the function names which will look like:
RI_FKey_<action>_(upd|del)
for update or delete, <action> is the action defined.

On Sat, 17 Feb 2001, MMM wrote:

> Sorry for my bad English
>
> I'd like to know how I can see the foreign keys for a table.
>
> Is there a system table where I can do a Select?;
>
> Thank you.
>