Re: Modifying a foreign key constraint?

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Marc Branchaud <marcnarc(at)x2omedia(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Modifying a foreign key constraint?
Date: 2007-02-09 17:40:10
Message-ID: 352385.16551.qm@web31802.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-02-09 17:49:51 Re: Some unknown error in a function
Previous Message Jasbinder Singh Bali 2007-02-09 17:29:37 Some unknown error in a function