Bird
0
0

This AFTER INSERT trigger fails to compile:

medium📝 Debug Q7 of 15
SQL - Triggers
This AFTER INSERT trigger fails to compile:
CREATE TRIGGER trg AFTER INSERT ON orders FOR EACH ROW BEGIN INSERT INTO audit VALUES (NEW.id, CURRENT_TIMESTAMP); END;

What is the most likely error?
AFOR EACH ROW is not allowed in AFTER triggers.
BMissing column list in INSERT INTO audit statement.
CCURRENT_TIMESTAMP is invalid in triggers.
DAFTER INSERT triggers cannot use NEW keyword.
Step-by-Step Solution
Solution:
  1. Step 1: Check INSERT syntax

    INSERT statements should specify columns if table has multiple columns.
  2. Step 2: Identify missing column list

    Without column list, if audit table has more than two columns, error occurs.
  3. Final Answer:

    Missing column list in INSERT INTO audit statement. -> Option B
  4. Quick Check:

    Always specify columns in INSERT inside triggers [OK]
Quick Trick: Specify columns in INSERT statements inside triggers [OK]
Common Mistakes:
  • Assuming NEW keyword is invalid
  • Thinking CURRENT_TIMESTAMP is disallowed
  • Ignoring need for column list in INSERT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes