How often trigger updates work on multitask updates?

I created a trigger on update.

If I update 5 records in a table in one expression, how many times will the trigger fire? Does this change if I have multiple statements updating records in a single transaction?

Is it executed 5 times or only once after the completion of all transactions?

+5
source share
3 answers

It all depends on the type of trigger used.

  • a row level trigger will fire for each row affected by the DML operator (note that this is also true for statement INSERTbased on SELECT) or use multi-line syntax to insert more than one row at a time)
  • .

Oracle, PostgreSQL DB2 . Microsoft SQL Server , MySQL .

+9

SQL 2008: 1 , 5 , .

"INSERTED" "DELETED", .

5 , 1 , 5 .

+2

, SQL Server, .

, , , .

You can look at this turorial on SQL triggers. It covers everything.

Please note: if you use Oracle, the trigger may be row based. Not in SQL Server.

0
source

All Articles