在级联删除中触发调用

2022-01-01 00:00:00 mysql triggers cascade cascading-deletes

我在 MySQL 中有表A".它有一些对其他一些表(B"、C"、D"...)的级联删除的引用.当某些内容从A"中删除时,我需要使用触发器.当我直接从A"删除记录时,此触发器起作用.但它不适用于级联删除.是否存在任何版本的 MySQL,我的触发器可以与级联删除一起使用?或者,也许还有另一种调用方式

I have table "A" in MySQL. It has some references with cascade deleting to some other tables ("B", "C", "D" ...). I need to use a trigger when something deletes from "A". This trigger works when I delete records from "A" directly. But it doesn't work with cascade deleting. Does any version of MySQL exist where my trigger will work with cascade deleting? Or, maybe, there is another way to call

推荐答案

来自http://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html

级联外键操作不会激活触发器

Cascaded foreign key actions do not activate triggers

换句话说,您不能将触发器与级联删除一起使用.

In other words, you cannot use the trigger with cascaded deleting.

另见相关错误:

  • MySQL:https://bugs.mysql.com/bug.php?id=11472
  • MariaDB:https://jira.mariadb.org/browse/MDEV-19402

相关文章