Middle
What is a trigger in a database?
sobes.tech AI
Answer from AI
A trigger in a database is a special object that automatically performs a specified set of actions (such as SQL queries) when a certain event (INSERT, UPDATE, DELETE) occurs on a table.
Main features:
- Automation of business logic at the database level.
- Ensuring data integrity.
- Logging changes.
Example: when a new record is added to the orders table, a trigger can automatically update summary metrics or verify data correctness.
Triggers are useful when it is necessary to guarantee the execution of certain operations regardless of the application working with the database.