Why to Create Trigger?

DML triggers run when a user tries to modify data through a data manipulation language

data manipulation language
A data manipulation language (DML) is a computer programming language used for adding (inserting), deleting, and modifying (updating) data in a database. ... A popular data manipulation language is that of Structured Query Language (SQL), which is used to retrieve and manipulate data in a relational database.
› wiki › Data_manipulation_language
(DML) event. DML events are INSERT, UPDATE, or DELETE statements on a table or view. These triggers fire when any valid event fires, whether table rows are affected or not.

Why do we create triggers?

Triggers help the database designer ensure certain actions, such as maintaining an audit file, are completed regardless of which program or user makes changes to the data. The programs are called triggers since an event, such as adding a record to a table, fires their execution.

What are the benefits of trigger?

Following are the benefits of triggers.
  • Generating some derived column values automatically.
  • Enforcing referential integrity.
  • Event logging and storing information on table access.
  • Auditing.
  • Synchronous replication of tables.
  • Imposing security authorizations.
  • Preventing invalid transactions.
Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.