1Z0-909 practice question 3 of 15
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 = ©subtotal + NEW.amount; Which is true for the income table?
Full set: 65 questionsThe trigger is declared BEFORE INSERT ON income FOR EACH ROW. MySQL therefore fires the trigger once for every row that an INSERT statement attempts to add to income, immediately before each row is written. No other DML statement (UPDATE, DELETE) or timing (AFTER) will invoke it. Consequently, executing any INSERT statement on income is what causes the trigger to run, making option D the only accurate choice.
A. Uses AFTER timing; the trigger is defined with BEFORE, so it does not fire after the row is stored.
B. The SET statement is the trigger body; it runs because the trigger fires, not vice-versa.
C. Trigger timing is tied to INSERT, not UPDATE, so updates never invoke it.
1. MySQL 8.0 Reference Manual, §13.1.22 “CREATE TRIGGER Statement”, paragraph “BEFORE INSERT triggers are activated for each row that is inserted.” (https://dev.mysql.com/doc/refman/8.0/en/create-trigger.html)
2. Oracle MySQL 8.0 Developer Guide, Chapter “Using Triggers”, subsection “Trigger Activation Timing and Event”, lines describing “BEFORE INSERT … fires once for each row inserted.” (Document ID: E87930-19, PDF p. 865)
Keep practicing
Take the free 1Z0-909 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 1Z0-909 practice questions
- Question 4Examine this statement which executes successfully: CREATE TABLE 'fshop’ ('product' JSON …
- Question 5Which two statements are true about aggregate functions?
- Question 6Examine this statement and output: CREATE TABLE geom (g GEOMETRY NOT NOLL, SPATIAL INDEX(…
- Question 12You are using buffered queries with PHP mysqli in a browser-based web application. Which …
