pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roger Tannous <roger77_lb@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Locating ( FKs ) References to a Primary Key
Date: Wed, 17 Aug 2005 22:58:21 -0700 (PDT)
Message-ID: <20050818055821.34703.qmail@web51902.mail.yahoo.com> (raw)

Dmitri, 

Thanks !! I got exactly what I wanted :)

In fact, I used your query like this:

SELECT
	cl.relname AS FK_table_name, 
	a.attname AS FK_column_name,
	clf.relname AS PK_table_name,
	af.attname AS PK_column_name 
FROM pg_catalog.pg_attribute a
JOIN pg_catalog.pg_class cl ON (a.attrelid = cl.oid AND cl.relkind =
'r')
JOIN pg_catalog.pg_namespace n ON (n.oid = cl.relnamespace)
JOIN pg_catalog.pg_constraint ct ON (a.attrelid = ct.conrelid AND
ct.confrelid != 0 AND ct.conkey[1] = a.attnum)
JOIN pg_catalog.pg_class clf ON (ct.confrelid = clf.oid AND clf.relkind
= 'r')
JOIN pg_catalog.pg_namespace nf ON (nf.oid = clf.relnamespace)
JOIN pg_catalog.pg_attribute af ON (af.attrelid = ct.confrelid AND
af.attnum = ct.confkey[1])
WHERE n.nspname = nf.nspname AND n.nspname = 'public' AND clf.relname like
'sip_emp' AND af.attname = 'id';


Best Regards,
Roger Tannous.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



view thread (3+ messages)

Message-ID: <20050818055821.34703.qmail@web51902.mail.yahoo.com>
Permalink:  ../20050818055821.34703.qmail@web51902.mail.yahoo.com/
Also on:    postgresql.org/message-id/20050818055821.34703.qmail@web51902.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: roger77_lb@yahoo.com
  Subject: Re: Locating ( FKs ) References to a Primary Key
  In-Reply-To: <20050818055821.34703.qmail@web51902.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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