15.00 - When to Use Statement Triggers - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1184-015K

When to Use Statement Triggers

Statement triggers are often a better choice than row triggers for multirow operations like an INSERT ... SELECT statement because their triggered action is executed only once, while the triggered action for a row trigger is executed once per each qualifying row of the transition table, which can impact performance negatively.

The WHEN condition is tested only once in statement triggers, and it might access information from OLD TABLE or NEW TABLE columns as well as columns from the triggering table.

Because the WHEN condition must provide a single result, aggregation is a typical use for OLD TABLE and NEW TABLE column references.

Although statement triggers fire only once, the join conditions created by WHEN conditions can have a performance impact. Note that specifying an OLD_NEW_TABLE reference, which is valid only for UPDATE AFTER statement triggers, eliminates a join operation and often eliminates the need for WHERE clause filtering conditions.