From: Chris Mair <chrisnospam@1006.org>
To: Alexander Burbello <alexander@cresoltec.com.br>
Cc: pgsql-admin@postgresql.org
Subject: Re: Find out foreign key
Date: Thu, 10 Aug 2006 21:09:21 +0200
Message-ID: <1155236961.5893.43.camel@dell.home.lan> (raw)
In-Reply-To: <44DB23CA.50804@cresoltec.com.br>
References: <44DB23CA.50804@cresoltec.com.br>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: chrisnospam@1006.org, alexander@cresoltec.com.br
Subject: Re: Find out foreign key
In-Reply-To: <1155236961.5893.43.camel@dell.home.lan>
References: <44DB23CA.50804@cresoltec.com.br> <1155236961.5893.43.camel@dell.home.lan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox