Search This Blog

What are the pros and cons of using triggers?

Expected answer:

A trigger is one or more statements of SQL that are being executed in event of data modification in a table to which the trigger belongs. Triggers enhance the security, efficiency, and standardization of databases.
Triggers can be beneficial when used:

– to check or modify values before they are actually updated or inserted in the database. This is useful if you need to transform data from the way the user sees it to some internal database format.

– to run other non-database operations coded in user-defined functions

– to update data in other tables. This is useful for maintaining relationships between data or in keeping audit trail information.

– To check against other data in the table or in other tables. This is useful to ensure data integrity when referential integrity constraints aren’t appropriate, or when table check constraints limit checking to the current table only.