pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Find out foreign key
2+ messages / 2 participants
[nested] [flat]

* Find out foreign key
@ 2006-08-10 12:17  Alexander Burbello <alexander@cresoltec.com.br>
  0 siblings, 1 reply; 2+ messages in thread

From: Alexander Burbello @ 2006-08-10 12:17 UTC (permalink / raw)
  To: pgsql-admin

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.



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

* Re: Find out foreign key
@ 2006-08-10 19:09  Chris Mair <chrisnospam@1006.org>
  parent: Alexander Burbello <alexander@cresoltec.com.br>
  0 siblings, 0 replies; 2+ messages in thread

From: Chris Mair @ 2006-08-10 19:09 UTC (permalink / raw)
  To: Alexander Burbello <alexander@cresoltec.com.br>; +Cc: pgsql-admin


> 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





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


end of thread, other threads:[~2006-08-10 19:09 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-10 12:17 Find out foreign key Alexander Burbello <alexander@cresoltec.com.br>
2006-08-10 19:09 ` Chris Mair <chrisnospam@1006.org>

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