Bird
0
0

You have a view:

hard📝 Application Q9 of 15
SQL - Views
You have a view:
CREATE VIEW v_orders AS SELECT order_id, customer_id, order_date FROM orders;

You want to allow updates on customer_id but prevent updates on order_date. How can you enforce this?
AUse INSTEAD OF triggers on the view to control updates
BAdd a CHECK constraint on the view for order_date
CCreate the view with GROUP BY order_date
DUse WITH CHECK OPTION in the view definition
Step-by-Step Solution
Solution:
  1. Step 1: Understand update control on views

    Standard views cannot restrict updates on specific columns; triggers can intercept and control update behavior.
  2. Step 2: Analyze options

    Use INSTEAD OF triggers on the view to control updates uses INSTEAD OF triggers to allow or block updates on columns. CHECK constraints and WITH CHECK OPTION do not restrict column updates. GROUP BY blocks updates.
  3. Final Answer:

    Use INSTEAD OF triggers on the view to control updates -> Option A
  4. Quick Check:

    Triggers control column-level updates on views [OK]
Quick Trick: Use triggers to control updates on specific view columns [OK]
Common Mistakes:
MISTAKES
  • Thinking CHECK constraints restrict column updates
  • Using GROUP BY which blocks updates
  • Assuming WITH CHECK OPTION limits column updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes