Search Postgresql Archives

Foreign Key 'walker'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux