Bird
0
0

How can a BEFORE UPDATE trigger be used together with a BEFORE INSERT trigger to maintain a column's value always uppercase?

hard📝 Application Q9 of 15
SQL - Triggers
How can a BEFORE UPDATE trigger be used together with a BEFORE INSERT trigger to maintain a column's value always uppercase?
AOnly BEFORE INSERT modifies the column, BEFORE UPDATE does nothing
BBoth triggers modify NEW.column to UPPER(NEW.column) before saving
COnly BEFORE UPDATE modifies the column, BEFORE INSERT does nothing
DUse AFTER triggers to modify the column after saving
Step-by-Step Solution
Solution:
  1. Step 1: Understand data modification timing

    BEFORE INSERT and BEFORE UPDATE triggers run before saving new or updated rows.
  2. Step 2: Modify NEW.column in both triggers

    To keep column uppercase always, both triggers must convert NEW.column to uppercase.
  3. Final Answer:

    Both triggers modify NEW.column to UPPER(NEW.column) before saving -> Option B
  4. Quick Check:

    Use BEFORE triggers on insert and update to enforce data format [OK]
Quick Trick: Modify NEW values in both BEFORE INSERT and UPDATE triggers [OK]
Common Mistakes:
  • Modifying only one trigger event
  • Using AFTER triggers which run too late
  • Not modifying NEW values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes