Bird
0
0

What is the most likely cause?

medium📝 Debug Q14 of 15
PostgreSQL - Views and Materialized Views
You have a materialized view mv_orders created as CREATE MATERIALIZED VIEW mv_orders AS SELECT * FROM orders;. You try to refresh it using REFRESH MATERIALIZED VIEW mv_orders; but get an error: ERROR: permission denied for relation orders. What is the most likely cause?
AThe user running the refresh lacks SELECT permission on the base table orders
BThe materialized view name is misspelled
CREFRESH MATERIALIZED VIEW syntax is incorrect
DMaterialized views cannot be refreshed after creation
Step-by-Step Solution
Solution:
  1. Step 1: Understand permission requirements for refreshing

    Refreshing a materialized view requires SELECT permission on the underlying base tables.
  2. Step 2: Analyze the error message

    The error says permission denied on relation orders, indicating the user lacks SELECT rights on that table.
  3. Final Answer:

    The user running the refresh lacks SELECT permission on the base table orders -> Option A
  4. Quick Check:

    Permission denied = missing SELECT rights [OK]
Quick Trick: Check base table permissions if refresh gives permission denied [OK]
Common Mistakes:
  • Assuming syntax error instead of permission issue
  • Ignoring user privileges on base tables
  • Thinking materialized views cannot be refreshed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes