What is the purpose of a database trigger?
a) To automatically execute a predefined action in response to certain events
b) To create a backup of the database
c) To monitor user access to the database
d) To restrict access to specific rows in a table
Answer:
a) To automatically execute a predefined action in response to certain events
Explanation:
A database trigger is a procedural code that is automatically executed in response to certain events on a particular table or view. Triggers can be used to enforce business rules, maintain audit trails, or automate system tasks.
For example, a trigger might automatically log changes to a specific table, or it could ensure that data integrity constraints are met when inserting or updating records. Triggers can be defined for events like INSERT, UPDATE, or DELETE.
Triggers help automate repetitive tasks and ensure consistent behavior across database operations.