X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 7F6A69FB31E for ; Thu, 10 Aug 2006 16:09:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 64459-02 for ; Thu, 10 Aug 2006 19:09:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from my.endian.it (unknown [62.146.87.34]) by postgresql.org (Postfix) with ESMTP id 247129FB2F8 for ; Thu, 10 Aug 2006 16:09:24 -0300 (ADT) Received: from dell.home.lan (host188-110.pool874.interbusiness.it [87.4.110.188]) (authenticated (0 bits)) by my.endian.it (8.11.6/8.11.6) with ESMTP id k7AJHET31466; Thu, 10 Aug 2006 21:17:14 +0200 Subject: Re: Find out foreign key From: Chris Mair To: Alexander Burbello Cc: pgsql-admin@postgresql.org In-Reply-To: <44DB23CA.50804@cresoltec.com.br> References: <44DB23CA.50804@cresoltec.com.br> Content-Type: text/plain Date: Thu, 10 Aug 2006 21:09:21 +0200 Message-Id: <1155236961.5893.43.camel@dell.home.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-27) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/148 X-Sequence-Number: 22691 > 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