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

From Erwin Moller
Subject Foreign Key 'walker'?
Date
Msg-id 4922D568.2090408@darwine.nl
Whole thread Raw
Responses Re: Foreign Key 'walker'?
Re: Foreign Key 'walker'?
List pgsql-general
Hi group,

Considering following (simplified) example:

CREATE TABLE tblnr1(
  nr1id SERIAL PRIMARY KEY,
  firstname TEXT
);
CREATE TABLE tblnr2(
  nr2id SERIAL PRIMARY KEY,
  nr1id INTEGER REFERENCES tblnr1(nr1id)
);
CREATE TABLE tblnr3(
   nr3id SERIAL PRIMARY KEY,
   nr2id INTEGER REFERENCES tblnr2(nr2id)
);

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)
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'.

I want this because:
1) I hate DELETE CASCADE because I am chicken (So I use a script to
delete all related records in the right order in a transaction)
2) I have a lot of tables and am afraid I miss some. And I am also a bit
lazy .-)

Thanks for your time.

Regards,
Erwin Moller

pgsql-general by date:

Previous
From: Gustavo Rosso
Date:
Subject: Re: Urgent - Grant
Next
From: "DANG Trieu"
Date:
Subject: Slow queries when ORDER BY ... DESC with table inheritance (no index scan backwards)