Bird
0
0

You want to make a complex view updatable that joins orders and customers tables. Which PostgreSQL feature should you use to allow updates through this view?

hard📝 Application Q15 of 15
PostgreSQL - Views and Materialized Views
You want to make a complex view updatable that joins orders and customers tables. Which PostgreSQL feature should you use to allow updates through this view?
AUse a materialized view instead of a regular view
BCreate INSTEAD OF triggers on the view to handle updates
CAdd a WHERE clause to the view to filter rows
DCreate a function that returns the joined data
Step-by-Step Solution
Solution:
  1. Step 1: Understand limitations of updatable views with joins

    Views joining multiple tables are not automatically updatable in PostgreSQL.
  2. Step 2: Use INSTEAD OF triggers to enable updates

    INSTEAD OF triggers let you define custom update logic on complex views, making them updatable.
  3. Final Answer:

    Create INSTEAD OF triggers on the view to handle updates -> Option B
  4. Quick Check:

    INSTEAD OF triggers enable updates on complex views [OK]
Quick Trick: Use INSTEAD OF triggers for complex view updates [OK]
Common Mistakes:
  • Thinking WHERE clause makes view updatable
  • Confusing materialized views with updatable views
  • Believing functions replace update triggers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes