Subject Re: From Restriced to CASCADE on delete
Author javaguru_uk
--- In firebird-support@yahoogroups.com, "federonline"
<federonline@...> wrote:

> The metadata looks like this:
> CREATE TABLE DATA (
> MAC VARCHAR(32) NOT NULL,
> DATETIME_STAMP TIMESTAMP default NULL);
>
> /* Foreign key(s) */
>
> ALTER TABLE DATA ADD CONSTRAINT FK_DATA_SENSOR_MAC
> FOREIGN KEY (MAC) REFERENCES SENSOR(MAC)
> ON UPDATE RESTRICT ON DELETE RESTRICT;
>
> Is there an easy ALTER I can do to the FK to cascade my deletes??

This should do the trick:

ALTER TABLE DATA ADD CONSTRAINT FK_DATA_SENSOR_MAC
FOREIGN KEY (MAC) REFERENCES SENSOR(MAC)
ON UPDATE NO ACTION ON DELETE CASCADE;

I have replaced the RESTRICT keyword with NO ACTION because the
RESTRICT keyword is something new to FB2.0+, I think. Not quite sure
cause I have never used that keyword.

All the best,

Fidel.