1Z0-909 · Question #24
Examine these commands which execute successfully: mYsql> CREATE TABLE income (acct_num INT, amount DECIMAL(10,2)); mysql> CREATE TRIGGER subtotal BEFORE INSERT ON income FOR EACH ROW SET @subtotal…
The correct answer is D. Execution of an insert statement causes the trigger to activate. Option D is correct because the trigger is defined with BEFORE INSERT ON income, meaning any time an INSERT statement is executed against the income table, the trigger activates - specifically just before the row is written. Why the distractors are wrong: A is wrong because the…
Question
Examine these commands which execute successfully:
mYsql> CREATE TABLE income (acct_num INT, amount DECIMAL(10,2)); mysql> CREATE TRIGGER subtotal BEFORE INSERT ON income FOR EACH ROW SET @subtotal = ﹕ubtotal + NEW.amount; Which is true for the income table?
Options
- AThe trigger activates after any row has been inserted into the table.
- BThe trigger body set causes trigger activation.
- CThe trigger activates after any row in the table has been updated.
- DExecution of an insert statement causes the trigger to activate.
How the community answered
(45 responses)- A2% (1)
- B7% (3)
- C13% (6)
- D78% (35)
Explanation
Option D is correct because the trigger is defined with BEFORE INSERT ON income, meaning any time an INSERT statement is executed against the income table, the trigger activates - specifically just before the row is written.
Why the distractors are wrong:
- A is wrong because the timing keyword is
BEFORE, notAFTER- the trigger fires before the insert completes, not after. - B confuses cause and effect: the
SETstatement is the trigger body (what runs when triggered), not the mechanism that causes activation; theINSERTevent causes activation. - C is wrong on two counts - the event is
INSERT, notUPDATE, and the timing isBEFORE, notAFTER.
Memory tip: Read the trigger definition left to right - BEFORE INSERT ON income tells you when (before), what event (insert), and on which table (income). The event keyword (INSERT, UPDATE, or DELETE) always determines what SQL operation activates the trigger.
Topics
Community Discussion
No community discussion yet for this question.