ITPEC FE Morning April 2020 Question 27
Which of the following is the database function that is automatically executed when a specific action such as update, delete, or insert occurs within a database?
Explanation
Trigger — a procedure stored in the database that runs automatically when an INSERT, UPDATE or DELETE happens on its table.
A trigger is defined once, together with the event it watches, for example AFTER UPDATE ON orders. Whenever that event occurs, the DBMS runs it without anyone calling it. Typical uses are writing an audit log, keeping a derived total up to date and enforcing a rule that a constraint cannot express.
Answer (c)
Why not others:
- •(a) Cursor — a pointer that lets a program fetch the rows of a query result one at a time; the program opens and moves it
- •(b) Stored procedure — also stored in the database, but it runs only when an application or user calls it
- •(d) Update query — an ordinary
UPDATEstatement; it is the kind of action that can fire a trigger, not something that runs by itself
Key rule: Stored procedure = called explicitly; trigger = fired by an event on a table.
Databases · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.