Re: A Query on PG_ tables
Stephan Szabo <sszabo@kick.com>
From: "Stephan Szabo" <sszabo@kick.com>
To: "NRonayette" <r97m10@socotec.fr>
Cc: <pgsql-general@postgresql.org>
Date: 2000-06-19T18:48:54Z
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@socotec.fr> To: <pgsql-general@postgresql.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. >