Re: A Query on PG_ tables

From: "Stephan Szabo" <sszabo(at)kick(dot)com>
To: "NRonayette" <r97m10(at)socotec(dot)fr>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: A Query on PG_ tables
Date: 2000-06-19 18:48:54
Message-ID: 00ef01bfda1f$04c73a30$0c64010a@kick.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Okay, this gets a little wierd, but, for now:

What you'll probably want is
select proname, tgargs from pg_proc, pg_trigger where
pg_proc.oid=pg_trigger.tgfoid and tgisconstraint=1;

Each properly defined foreign key constraint will have three triggers.

The proname for foreign key constraints will look like on of the following:
RI_FKey_check_ins
RI_FKey_<action>_del - action for deleting a row on the referenced table
RI_FKey_<action>_upd - action for updating a row on the referenced table

The tgargs is layed out as follows:
<constraint name>\000<referencing table>\000<referenced table>\000
<match type>\000<referencing col1>\000<referenced col1>\000
[<referencing col2>\000<referenced col2>\000...]

----- Original Message -----
From: "NRonayette" <r97m10(at)socotec(dot)fr>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Monday, June 19, 2000 1:52 AM
Subject: [GENERAL] A Query on PG_ tables

> Hi everybody,
>
> I'm using Postgresql 7.0.
>
> I want to find, by a query on the postgres table (like pg_class,
> pg_attribute, pg_trigger, etc....), the name of all the colonnes that
> are foreign key on my base.
>
> Pg_trigger gives me some information about the foreigns key i added on
> my tables (name, id etc..) but i don't know how to join this information
> with another pg_<table> (for example, pg_attribute or else) to find the
> name of my colonnes that are foreign key.
>
> Someone have an idear ?
>
> I hope i was clear with my poor English...
>
> Thanks for your answers.
>
> Nicolas.
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2000-06-19 19:31:41 NOTICE: Unrecognized variable client_encoding
Previous Message Tom Lane 2000-06-19 18:16:19 Re: current database?