Re: Foreign Key 'walker'? - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Foreign Key 'walker'?
Date
Msg-id gfuo36$r28$1@ger.gmane.org
Whole thread Raw
In response to Foreign Key 'walker'?  (Erwin Moller <erwin@darwine.nl>)
Responses Re: Foreign Key 'walker'?
List pgsql-general
Erwin Moller, 18.11.2008 15:47:
> Suppose I want to delete a record in tblnr1.
> Does Postgres has some command/procedure/function to list tables that
> have FK constraints on that table (tblnr1)

That could be resolved with a query against the INFORMATION_SCHEMA

Something like

SELECT c.table_name || ' references ' || tu.table_name
FROM information_schema.table_constraints c
   JOIN information_schema.constraint_table_usage tu
      ON (c.constraint_name = tu.constraint_name AND c.table_schema = tu.table_schema)
WHERE c.constraint_type = 'FOREIGN KEY';

> and lists also the tables that have a FK constraint on tables that have
> a FK constraint on the first? etc.
> So I would like some kind of FK 'walker'.

That would be your front-end that displays that (or some nested self-join using the above statement)

Regards
Thomas

pgsql-general by date:

Previous
From: tv@fuzzy.cz
Date:
Subject: Re: Slow queries when ORDER BY ... DESC with table inheritance (no index scan backwards)
Next
From: Erwin Moller
Date:
Subject: Re: Foreign Key 'walker'?