多行删除时在MySQL表上触发 [英] Trigger on MySQL table when multiple rows deleted

查看:75
本文介绍了多行删除时在MySQL表上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个触发器,该触发器在删除一行之前运行,该触发器更新汇总该表中数据的表。当我一次删除一行时,触发器工作良好。但是,如果我要使用一条语句一次删除多行

I wrote a trigger that runs before a row is deleted that updates a table summarizing the data from this table. The trigger works well when I delete a single row at a time. However, if I were to delete multiple rows at once with a statement like

DELETE FROM myTable WHERE id BETWEEN 1 and 100;

触发器将在删除下一行之前完全在第一行运行,还是将触发器全部运行

Will the trigger completely run on the first row before the next row is deleted or will the triggers run all at the same time?

推荐答案

触发器将针对每一行完全运行,请参见触发常见问题解答

The trigger will completely run for every single row, see Trigger FAQ


A.5.3:MySQL 5.6是否具有语句级或行级触发器?

A.5.3: Does MySQL 5.6 have statement-level or row-level triggers?

在MySQL 5.6中,所有触发器都是按行行的,也就是说,对于插入,更新或删除的每一行,触发器均被激活
。 MySQL
5.6不支持使用FOR EACH STATEMENT的触发器。

In MySQL 5.6, all triggers are FOR EACH ROW—that is, the trigger is activated for each row that is inserted, updated, or deleted. MySQL 5.6 does not support triggers using FOR EACH STATEMENT.

对于当前最新版本 MySQL 5.7

这篇关于多行删除时在MySQL表上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆