When table was set up with a column that has a foreign key and is set to cascade (delete child when parent is deleted) what would the sql command to change this to be restrict? (can't delete parent if it has children)
A:
ALTER TABLE DROP FOREIGN KEY fk_name;
ALTER TABLE ADD FOREIGN KEY fk_name(fk_cols)
REFERENCES tbl_name(pk_names) ON CASCADE RESTRICT;
pascal
2010-07-29 03:55:03
fk_name is the column name?
Moak
2010-07-29 07:02:04
helped me find the solution `ALTER TABLE table_name ADD` ... `ON DELETE RESTRICT`
Moak
2010-07-29 07:13:07
No, fk_name is the constraint name.It's optional to provide one.I'm not sure but maybe you can retrieve it using `SHOW CREATE TABLE`.
pascal
2010-07-29 07:16:16