Unix Technical Forum

dependency ?

This is a discussion on dependency ? within the Pgsql General forums, part of the PostgreSQL category; --> Hi, I was wondering if there is any way to use psql to list tables that are dependent to ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 01:42 PM
TWENGER2@wi.rr.com
 
Posts: n/a
Default dependency ?

Hi,
I was wondering if there is any way to use psql to list tables that
are dependent to a specific table. Instead of going through every table
in my database and looking for foreign keys, can I somehow get an entire
list of these dependent tables? Any help would be much appreciated, thanks!

Tyson

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 01:42 PM
Tom Lane
 
Posts: n/a
Default Re: dependency ?

TWENGER2@wi.rr.com writes:
> I was wondering if there is any way to use psql to list tables that
> are dependent to a specific table. Instead of going through every table
> in my database and looking for foreign keys, can I somehow get an entire
> list of these dependent tables? Any help would be much appreciated, thanks!


pg_depend might help, although I think it'd be a multi-step link.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 01:42 PM
Brian Wipf
 
Posts: n/a
Default Re: dependency ?

On 29-Jan-07, at 1:06 PM, TWENGER2@wi.rr.com wrote:
> I was wondering if there is any way to use psql to list tables that
> are dependent to a specific table. Instead of going through every
> table
> in my database and looking for foreign keys, can I somehow get an
> entire
> list of these dependent tables? Any help would be much
> appreciated, thanks!


You could do this easily enough in the shell. For example, If I
wanted to find all tables that reference foo_table:

psql -U postgres database_name -c '\d *' | egrep "(Table |REFERENCES
foo_table)" | grep -B1 'REFERENCES foo_table' | grep 'Table ' | cut -
d '"' -f 2

should do the trick.

Brian Wipf


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:38 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com