Re: ALTER TABLE -- how to add ON DELETE CASCADE?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: felix(at)crowfix(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ALTER TABLE -- how to add ON DELETE CASCADE?
Date: 2006-03-07 22:36:37
Message-ID: 6042.1141770997@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

felix(at)crowfix(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message felix 2006-03-07 22:42:14 Re: ALTER TABLE -- how to add ON DELETE CASCADE?
Previous Message felix 2006-03-07 22:06:11 ALTER TABLE -- how to add ON DELETE CASCADE?