Bird
0
0

You want to log a summary message once after any UPDATE statement on a table, regardless of how many rows are changed. Which trigger type and timing should you use?

hard📝 Application Q15 of 15
PostgreSQL - Triggers in PostgreSQL
You want to log a summary message once after any UPDATE statement on a table, regardless of how many rows are changed. Which trigger type and timing should you use?
AA BEFORE UPDATE row-level trigger
BAn AFTER UPDATE statement-level trigger
CAn AFTER UPDATE row-level trigger
DA BEFORE UPDATE statement-level trigger
Step-by-Step Solution
Solution:
  1. Step 1: Determine trigger timing for logging after update

    Logging after the update completes requires an AFTER trigger.
  2. Step 2: Choose trigger level for single summary message

    To log once per statement regardless of rows, use a statement-level trigger (FOR EACH STATEMENT).
  3. Final Answer:

    An AFTER UPDATE statement-level trigger -> Option B
  4. Quick Check:

    Summary logging = AFTER + statement-level trigger [OK]
Quick Trick: Use AFTER statement-level trigger for single summary action [OK]
Common Mistakes:
  • Using row-level triggers causing multiple logs
  • Using BEFORE triggers missing final state
  • Confusing timing and level for logging
  • Assuming row-level triggers can log once per statement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes