Bird
0
0

Given a row-level BEFORE INSERT trigger that increments a column value by 1, what will be the new value if the inserted row has column value 5?

medium📝 query result Q4 of 15
PostgreSQL - Triggers in PostgreSQL
Given a row-level BEFORE INSERT trigger that increments a column value by 1, what will be the new value if the inserted row has column value 5?
A5
BError
C0
D6
Step-by-Step Solution
Solution:
  1. Step 1: Understand BEFORE INSERT row-level trigger effect

    The trigger modifies the row before insertion, incrementing the column by 1.
  2. Step 2: Calculate new value

    Original value 5 plus 1 equals 6, so the inserted row will have 6.
  3. Final Answer:

    6 -> Option D
  4. Quick Check:

    Row-level BEFORE INSERT trigger increments value = 6 [OK]
Quick Trick: BEFORE INSERT row-level triggers can modify row values [OK]
Common Mistakes:
  • Assuming original value remains unchanged
  • Confusing BEFORE and AFTER timing
  • Expecting error without cause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes