pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Finding all References to a Primary Key
2+ messages / 2 participants
[nested] [flat]

* Finding all References to a Primary Key
@ 2008-03-26 18:19 Matthew T. O'Connor <matthew@zeut.net>
  2008-03-27 15:24 ` Re: Finding all References to a Primary Key Erik Jones <erik@myemma.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Matthew T. O'Connor @ 2008-03-26 18:19 UTC (permalink / raw)
  To: pgsql-sql

I'm sorry if this is has been discussed, but I tried to find the answer 
in the archives and failed, so...

How do I find all the rows in other tables that reference a specific row 
in another table?  I'm only trying to find rows that are in tables where 
there is a Foreign Key referencing the primary key of the table in question.

Example:
Table People has a primary key of people_id
There are say 20 tables that have foreign keys referencing people.people_id
How do I find all the rows in all of those 20 tables that reference a 
particular person in the people table?


Thank you in advance,

Matthew O'Connor



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Finding all References to a Primary Key
  2008-03-26 18:19 Finding all References to a Primary Key Matthew T. O'Connor <matthew@zeut.net>
@ 2008-03-27 15:24 ` Erik Jones <erik@myemma.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Erik Jones @ 2008-03-27 15:24 UTC (permalink / raw)
  To: Matthew T. O'Connor <matthew@zeut.net>; +Cc: pgsql-sql


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  
> answer in the archives and failed, so...
>
> How do I find all the rows in other tables that reference a specific  
> row in another table?  I'm only trying to find rows that are in  
> tables where there is a Foreign Key referencing the primary key of  
> the table in question.
>
> Example:
> Table People has a primary key of people_id
> There are say 20 tables that have foreign keys referencing  
> people.people_id
> How do I find all the rows in all of those 20 tables that reference  
> a particular person in the people table?

pg_catalog.pg_constraint has that info.

Erik Jones

DBA | Emma®
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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2008-03-27 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-03-26 18:19 Finding all References to a Primary Key Matthew T. O'Connor <matthew@zeut.net>
2008-03-27 15:24 ` Erik Jones <erik@myemma.com>

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