Bird
0
0

Consider this AFTER INSERT trigger on table 'orders':

medium📝 query result Q4 of 15
PostgreSQL - Triggers in PostgreSQL
Consider this AFTER INSERT trigger on table 'orders':
CREATE TRIGGER trg_after_insert AFTER INSERT ON orders FOR EACH ROW EXECUTE FUNCTION notify_insert();

If a new row is inserted, what happens first?
AThe notify_insert() function runs after the row is inserted.
BThe notify_insert() function runs before the row is inserted.
CThe trigger prevents the row from being inserted.
DThe trigger runs only if the insert fails.
Step-by-Step Solution
Solution:
  1. Step 1: Understand AFTER INSERT trigger timing

    AFTER INSERT triggers run after the row is successfully inserted into the table.
  2. Step 2: Confirm trigger behavior

    The function notify_insert() executes only after the insert completes, not before or on failure.
  3. Final Answer:

    The notify_insert() function runs after the row is inserted. -> Option A
  4. Quick Check:

    AFTER INSERT trigger = function runs post-insert [OK]
Quick Trick: AFTER INSERT triggers run after data insertion completes [OK]
Common Mistakes:
  • Assuming trigger runs before insert
  • Thinking trigger can block insert
  • Believing trigger runs on insert failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes