Locating ( FKs ) References to a Primary Key - Mailing list pgsql-sql

From Roger Motorola
Subject Locating ( FKs ) References to a Primary Key
Date
Msg-id 20050817190650.93891.qmail@web51904.mail.yahoo.com
Whole thread Raw
List pgsql-sql
Hi to all, 

Is there any means by which one can get all Foreign Keys (References) that
'point' to a certain Primary Key for a given table ?

For instance, let's consider those three tables:

(NOTE: table contents here are not deeply thought of...)

// employees table
create table emp
(id serial primary key, 
first_name varchar not null, 
last_name varchar not null, 
.....................etc.);

// employee address
create table emp_address
(emp_id integer references emp (id), 
city integer references city (id), 
primary key (emp_id, city), 
comments varchar not null);

// employee categories ()
create table emp_categories
(emp_id integer references emp (id), 
institution integer references institutions (id),
unique (emp_id, institution), 
category integer references categories (id), 
primary key (emp_id, institution, category), 
description varchar not null);


So, can we issue a query that gets all references to emp.id ?
which should yield here:   emp_address.emp_id 
and emp_categories.emp_id


Thanks in advance, 
Roger Tannous.

    
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 


pgsql-sql by date:

Previous
From: Jeremy Semeiks
Date:
Subject: Re: Is it This Join Condition Do-Able?
Next
From: "Dmitri Bichko"
Date:
Subject: Re: Is it This Join Condition Do-Able?