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

selecting all tables with references

From: robert wing <wingairak(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: selecting all tables with references
Date: 2012-10-10 01:49:10
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
  Is there a feature in Postgres where we can perform a query that selects
all tables that reference a primary key?
  For example if I have three tables b.main(k integer primary key, v
primary key references b.main(k), v timestamp with time zone),
primary key references b.main(k), v timestamp with time zone)
  Currently I'm using a cascading type query but was curious if there was
way to perform queries using referenced keys.

  The psuedo code would look something like: select all tables where
b.main.k is referenced.
  The results would be rows/columns from b.main,,and

  I've searched through the Postgresql documentation, but didn't find the
solution I was looking for. Is there way to do this?

I posted this question on stackoverflow as well but received minimal
feedback, so thought I would try here as well. If interested the link is

  Robert Wing

pgsql-novice by date

Next:From: Josh KupershmidtDate: 2012-10-10 21:20:26
Subject: Re: check if type is valid pg type
Previous:From: Tom LaneDate: 2012-10-09 20:51:06
Subject: Re: Copy command-Out of memory error

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