Bird
0
0

You have a view:

hard📝 Application Q8 of 15
PostgreSQL - Views and Materialized Views
You have a view:
CREATE VIEW recent_orders AS SELECT * FROM orders WHERE order_date > CURRENT_DATE - INTERVAL '30 days' WITH CHECK OPTION;
How does WITH CHECK OPTION affect inserting an order dated 40 days ago through this view?
AThe insert is rejected because the order date is outside the view's range
BThe insert succeeds and the order is visible in the view
CThe insert succeeds but the order is hidden from the view
DThe insert changes the order date to current date automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view's filter condition

    Only orders within the last 30 days are included.
  2. Step 2: Analyze inserting an order dated 40 days ago

    WITH CHECK OPTION blocks inserts that don't satisfy this condition.
  3. Final Answer:

    The insert is rejected because the order date is outside the view's range -> Option A
  4. Quick Check:

    Inserts outside view filter = rejected [OK]
Quick Trick: Inserts outside date range fail with CHECK OPTION [OK]
Common Mistakes:
  • Assuming insert succeeds but order is hidden
  • Thinking insert changes date automatically
  • Believing insert always succeeds

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes