ad hoc referential integrity

From: Matt Tenenbaum <matt(at)tty1(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: ad hoc referential integrity
Date: 2003-07-15 04:39:53
Message-ID: 606FC028-B67E-11D7-BFF3-0003939515A2@tty1.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

At the outset I hope that this is the right place to ask this question
(also, I hope the question isn't a foolish one).

Say I created a couple tables A and B, where A contains a column p
which B references as a foreign key. Further say that, when I created
these tables, I meant to specify 'on delete cascade' for p in the
definition of B but didn't. What's the proper way to ensure both the
integrity of the tables and that, when I delete rows from A, the
corresponding rows from B are removed as well? (In particular, is there
a shorter way than dropping the table and recreating it? Are rules the
answer?)

Again, I hope this is the right place to answer this question; I guess
I'm not 'new' to SQL, but I'm still a bit rough around the edges, so
trying to find the answer on my own has been a bit slow-going.

Thanks for any help.
-matt

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2003-07-15 04:48:18 Re: ad hoc referential integrity
Previous Message Scott Cain 2003-07-14 17:01:36 Cannot insert dup id in pk