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

From Richard Broersma Jr
Subject Re: Modifying a foreign key constraint?
Date
Msg-id 352385.16551.qm@web31802.mail.mud.yahoo.com
Whole thread Raw
In response to Modifying a foreign key constraint?  (Marc Branchaud <marcnarc@x2omedia.com>)
Responses Re: Modifying a foreign key constraint?  (Marc Branchaud <marcnarc@x2omedia.com>)
List pgsql-general
> 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?

Sure there is, you can preform multiple alterations in one statement:

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

regards,
Richard Broersma Jr.

pgsql-general by date:

Previous
From: "Jasbinder Singh Bali"
Date:
Subject: Some unknown error in a function
Next
From: Tom Lane
Date:
Subject: Re: Some unknown error in a function