Is there some sort of magical SQL statement to delete a row and all its dependents (linked by foreign key constraints) WITHOUT altering the table to add ON DELETE CASCADE
or deleting each dependent row manually?
I am fantasizing something such as DELETE FROM `table_a` WHERE `id` = 1 ON DELETE CASCADE;
but I can't seem to find anything to this effect in the doc @ http://dev.mysql.com/doc/refman/5.5/en/delete.html
- I don't want to
ALTER
the table to change the constraints for just a one time operation and then revert it back using anotherALTER
- I don't want to execute something like
DELETE FROM `table_b` WHERE `a_id` = 1;
for each table containing a FK totable_a
Using MySQL 5.5 with InnoDB