Modifying a foreign key constraint?

From: Marc Branchaud <marcnarc(at)x2omedia(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Modifying a foreign key constraint?
Date: 2007-02-09 15:57:37
Message-ID: 45CC99F1.2070909@x2omedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc Branchaud 2007-02-09 16:01:25 Re: Modifying a foreign key constraint?
Previous Message Kenneth Downs 2007-02-09 14:58:29 Re: trigger for pg_authid