Modifying a foreign key constraint? - Mailing list pgsql-general

From Marc Branchaud
Subject Modifying a foreign key constraint?
Date
Msg-id 45CC99F1.2070909@x2omedia.com
Whole thread Raw
Responses Re: Modifying a foreign key constraint?  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-general
What's the best way to modify a foreign key constraint?

I need to change a foreign key from ON DELETE NO ACTION to ON DELETE
CASCADE.  Should I just drop the constraint and re-add it?  For example:

ALTER TABLE foo DROP CONSTRAINT foo_bar_id_fkey;

ALTER TABLE foo ADD FOREIGN KEY (foo_bar_id_fkey) REFERENCES bar(id) ON
DELETE CASCADE;

Is there a more compact way to do this, perhaps with a single ALTER
TABLE command?

Thanks!

        Marc

pgsql-general by date:

Previous
From: Marc Branchaud
Date:
Subject: Re: Modifying a foreign key constraint?
Next
From: "Merlin Moncure"
Date:
Subject: Re: Adding TEXT columns tanks performance?