Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

sfpug by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group