MySQL 删除 table 关于参照完整性规则

MySQL delete table with regard to referential integrity rules

我想删除 tableA,同时删除 tableB 中具有匹配 tableA.A_ID = tableB.A_ID

的所有行

目前我有一个外键设置为 CASCADE 删除和更新设置 TableB for tableB.A_ID.

通过

暂时关闭约束
SET SQL_SAFE_UPDATES = 0;

DELETE FROM tableB b WHERE EXISTS ( SELECT * FROM tableA a WHERE a.A_ID = b.A_ID )

DELETE FROM tableA;

SET SQL_SAFE_UPDATES = 1;