pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wiebe Cazemier <halfgaar@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: Primary key reference count
Date: Sun, 23 Apr 2006 17:27:58 +0200
Message-ID: <e2g6du$peg$1@sea.gmane.org> (raw)
References: <e258pv$5fc$1@sea.gmane.org>
	<20060419172117.GA206@alamut>

On Wednesday 19 April 2006 19:21, Volkan YAZICI wrote:

> Here's simple query, to list which table's which columns references to a
> specific table. (Hope this is what you asked for.)
> 
> SELECT TBL.table_name, COL.column_name
>     FROM information_schema.referential_constraints AS REF
>     INNER JOIN information_schema.table_constraints AS TBL
>                USING (constraint_name)
>     INNER JOIN information_schema.constraint_column_usage AS COL
>                USING (constraint_name)
>     INNER JOIN information_schema.table_constraints AS PRI
>                ON (PRI.constraint_name = REF.unique_constraint_name)
>     WHERE PRI.table_name = 'pri_id'; -- Your target table goes here.
> 
> This is a quick & dirty hack. Just wanted to show the possibility of the
> idea using information schema. (You don't want to deal with internal
> tables, ain't?)

I know the reply is somewhat late, but indeed, this would seem to be what I was
looking for. And, using the information schema instead of pg_catalog would
seem to be a better idea as well :)




view thread (7+ messages)

Message-ID: <e2g6du$peg$1@sea.gmane.org>
Permalink:  ../e2g6du$peg$1@sea.gmane.org/
Also on:    postgresql.org/message-id/e2g6du$peg$1@sea.gmane.org

 · 

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: halfgaar@gmx.net
  Subject: Re: Primary key reference count
  In-Reply-To: <e2g6du$peg$1@sea.gmane.org>

* 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