> 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.  

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to