Skip site navigation (1) Skip section navigation (2)

Re: Tracking back foreign keys?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Benjamin Smith <ben(at)charterworks(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Tracking back foreign keys?
Date: 2004-12-31 06:15:04
Message-ID: 20041231061504.GB17555@wolff.to (view raw or flat)
Thread:
Lists: pgsql-general
On Sun, Dec 26, 2004 at 09:43:59 -0800,
  Benjamin Smith <ben(at)charterworks(dot)net> wrote:
> 
> Something like 
> 
> Select pg_table.name from pg_table where pg_field references images.id
> 
> ? 
> 
> How else do I put it? The output I'd like would be something like
> images.id / tablename / table.primary key 
> 11 / Vendors / 14
> 12 / Customers / 9
> 
> Can this be done? 

You can use joins to get this information. To find orphaned images you
can use outer joins. To combine information from several tables in one
query you can union the queries for each table.

In response to

pgsql-general by date

Next:From: Jaime CasanovaDate: 2004-12-31 06:19:05
Subject: Re: [PATCHES] reqd patch
Previous:From: Michael FuhrDate: 2004-12-31 06:09:46
Subject: Re: [PATCHES] reqd patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group