| From: | Erwin Moller <erwin(at)darwine(dot)nl> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Foreign Key 'walker'? |
| Date: | 2008-11-18 14:47:04 |
| Message-ID: | 4922D568.2090408@darwine.nl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ries van Twisk | 2008-11-18 14:58:11 | Re: Foreign Key 'walker'? |
| Previous Message | Gustavo Rosso | 2008-11-18 14:46:07 | Re: Urgent - Grant |