Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C46212E005E for ; Thu, 27 Mar 2008 12:24:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 52983-05 for ; Thu, 27 Mar 2008 12:24:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtp126.iad.emailsrvr.com (smtp126.iad.emailsrvr.com [207.97.245.126]) by postgresql.org (Postfix) with ESMTP id 9F8642E004D for ; Thu, 27 Mar 2008 12:24:41 -0300 (ADT) Received: from relay2.r2.iad.emailsrvr.com (localhost [127.0.0.1]) by relay2.r2.iad.emailsrvr.com (SMTP Server) with ESMTP id D5C5F44C5DB; Thu, 27 Mar 2008 11:24:39 -0400 (EDT) Received: by relay2.r2.iad.emailsrvr.com (Authenticated sender: erik-AT-myemma.com) with ESMTP id AEBBA44C6A1; Thu, 27 Mar 2008 11:24:39 -0400 (EDT) Cc: pgsql-sql@postgresql.org Message-Id: <00F59014-2C8B-49D6-8ED8-57C34AC7ADF7@myemma.com> From: Erik Jones To: Matthew T. O'Connor In-Reply-To: <47EA93B2.8000206@zeut.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Finding all References to a Primary Key Date: Thu, 27 Mar 2008 10:24:39 -0500 References: <47EA93B2.8000206@zeut.net> X-Mailer: Apple Mail (2.919.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/200 X-Sequence-Number: 30528 On Mar 26, 2008, at 1:19 PM, Matthew T. O'Connor wrote: > I'm sorry if this is has been discussed, but I tried to find the =20 > answer in the archives and failed, so... > > How do I find all the rows in other tables that reference a specific =20= > row in another table? I'm only trying to find rows that are in =20 > tables where there is a Foreign Key referencing the primary key of =20 > the table in question. > > Example: > Table People has a primary key of people_id > There are say 20 tables that have foreign keys referencing =20 > people.people_id > How do I find all the rows in all of those 20 tables that reference =20= > a particular person in the people table? pg_catalog.pg_constraint has that info. Erik Jones DBA | Emma=AE erik@myemma.com 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com