Changing a foreign key constraint?

From: David Fetter <david(at)fetter(dot)org>
To: SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Changing a foreign key constraint?
Date: 2003-04-04 05:09:00
Message-ID: 20030404050900.GL18584@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug

Kind people,

I'd like to change a foreign key constraint, 'cause it's not doing the
right thing right now.

Example DDL's below...

CREATE TABLE foo (
foo_id SERIAL NOT NULL PRIMARY KEY
, ...
);

CREATE TABLE bar (
...
, foo_id INTEGER NOT NULL REFERENCES foo(foo_id)
...
);

I'd like to change that to

, foo_id INTEGER NOT NULL REFERNCES foo(foo_id) ON DELETE CASCADE

Is there any way to do this short of dropping & re-creating the db?

Big TIA for any hints, tips or pointers on this :)

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778

Responses

Browse sfpug by date

  From Date Subject
Next Message Stephan Szabo 2003-04-04 06:06:23 Re: Changing a foreign key constraint?
Previous Message Dror Matalon 2003-03-25 20:13:22 Re: pghoster.com