Altering constraint delete action

Posted by Hobhouse on Stack Overflow See other posts from Stack Overflow or by Hobhouse
Published on 2009-08-19T18:21:43Z Indexed on 2010/04/09 21:03 UTC
Read the original article Hit count: 310

Filed under:
|
|

I did this:

ALTER TABLE `db`.`my_table`
ADD CONSTRAINT FOREIGN KEY (`my_second_table_id`)
REFERENCES `my_second_table` (`id`);

I should have done this:

ALTER TABLE `db`.`my_table` 
ADD CONSTRAINT FOREIGN KEY (`my_second_table_id`) 
REFERENCES `my_second_table` (`id`) 
ON DELETE SET NULL;

Is it possible to ALTER this, or do I have to drop the constraint and add again?

© Stack Overflow or respective owner

Related posts about innodb

Related posts about foreign-keys