views:

39

answers:

1

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?

A: 

You can remove the effect of what you did, just replace 'ADD' with 'DROP'.

Zed