Re: ad hoc referential integrity

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Matt Tenenbaum <matt(at)tty1(dot)org>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: ad hoc referential integrity
Date: 2003-07-15 04:48:18
Message-ID: 20030714214641.B79686-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 15 Jul 2003, Matt Tenenbaum wrote:

> 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?)

If I'm understanding what you want, I'd suggest dropping the constraint
and re-adding it with the on delete cascade. If you're on 7.3 or better
you should be able to do this entirely with alter table, before that you
have to do a little more work.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Benoît Bournon 2003-07-15 06:42:14 Re: Recursive request ...
Previous Message Matt Tenenbaum 2003-07-15 04:39:53 ad hoc referential integrity