pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Matt Tenenbaum <matt@tty1.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: ad hoc referential integrity
Date: Mon, 14 Jul 2003 21:48:18 -0700 (PDT)
Message-ID: <20030714214641.B79686-100000@megazone.bigpanda.com> (raw)
In-Reply-To: <606FC028-B67E-11D7-BFF3-0003939515A2@tty1.org>

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.




view thread (2+ messages)

Message-ID: <20030714214641.B79686-100000@megazone.bigpanda.com>
Permalink:  ../20030714214641.B79686-100000@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20030714214641.B79686-100000@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, matt@tty1.org
  Subject: Re: ad hoc referential integrity
  In-Reply-To: <20030714214641.B79686-100000@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox