更新触发器多久触发一次多记录更新? [英] How often do Update triggers fire on a multi-record update?

查看:98
本文介绍了更新触发器多久触发一次多记录更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了更新触发器。

如果我要更新表中的5条记录,一条语句,触发器将执行多少次?如果我有多个语句更新单个事务中的记录,它会改变吗?

If I am updating 5 records in the table in a single statement, how many times will the trigger execute? Does it change if I have multiple statements updating the records in a single transaction?

它执行5次,还是在所有事务完成后才执行一次?

Does it execute 5 times, or only once after all the transactions are complete?

推荐答案

这完全取决于您使用的触发器的类型。

It all depends on the type of trigger you are using.


  • 将对受DML语句影响的每一行触发行级触发器(请注意,对于<$ c也是如此)基于 SELECT 或使用多行语法一次插入多个行的$ c> INSERT 语句)

  • 语句级别触发器将为整个语句触发一次。

  • a row level trigger will fire for each and every row that is affected by the DML statement (note this is also true for INSERT statements that are based on a SELECT or are using a multi-row syntax to insert more than one row at a time)
  • a statement level trigger will fire once for the whole statement.

Oracle,PostgreSQL和DB2支持行级和语句级触发器。 Microsoft SQL Server仅支持语句级触发器,而MySQL仅支持行级触发器。

Oracle, PostgreSQL and DB2 support both, row level and statement level triggers. Microsoft SQL Server only supports statement level triggers and MySQL only supports row level triggers.

这篇关于更新触发器多久触发一次多记录更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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