Re: ALTER TABLE -- how to add ON DELETE CASCADE? - Mailing list pgsql-general

From Tom Lane
Subject Re: ALTER TABLE -- how to add ON DELETE CASCADE?
Date
Msg-id 6042.1141770997@sss.pgh.pa.us
Whole thread Raw
In response to ALTER TABLE -- how to add ON DELETE CASCADE?  (felix@crowfix.com)
Responses Re: ALTER TABLE -- how to add ON DELETE CASCADE?  (felix@crowfix.com)
List pgsql-general
felix@crowfix.com writes:
>     ALTER TABLE A COLUMN AA ADD CONSTRAINT DELETE ON CASCADE

You're missing the specification of the foreign key, not to mention
spelling the CASCADE clause backwards.  Try

ALTER TABLE A ADD FOREIGN KEY(AA) REFERENCES B(BB) ON DELETE CASCADE

> \h alter table seems to be missing any way to add a constraint to a
> column.

It's there, though you have to look to \h create table to see the
alternatives for "table_constraint".

            regards, tom lane

pgsql-general by date:

Previous
From: felix@crowfix.com
Date:
Subject: ALTER TABLE -- how to add ON DELETE CASCADE?
Next
From: felix@crowfix.com
Date:
Subject: Re: ALTER TABLE -- how to add ON DELETE CASCADE?