Bird
0
0

Given the table products(id, name, price) and the view:

medium📝 query result Q4 of 15
SQL - Views
Given the table products(id, name, price) and the view:
CREATE VIEW v_expensive AS SELECT id, name FROM products WHERE price > 100;

Which of the following statements is true when trying to update v_expensive?
AYou can update the <code>name</code> of products with price > 100 through the view
BYou cannot update any rows through the view because of the WHERE clause
CYou can insert new rows through the view with any price
DYou can delete rows through the view regardless of price
Step-by-Step Solution
Solution:
  1. Step 1: Understand update behavior with WHERE in views

    Views with WHERE clauses can be updatable if based on a single table and no aggregates. Updates affect only rows visible through the view.
  2. Step 2: Analyze each option

    You can update the name of products with price > 100 through the view is correct because updating name for rows where price > 100 is allowed. You cannot update any rows through the view because of the WHERE clause is wrong; WHERE does not block updates. You can insert new rows through the view with any price is wrong; inserts must satisfy the WHERE condition. You can delete rows through the view regardless of price is wrong; deletes are limited to visible rows.
  3. Final Answer:

    You can update the name of products with price > 100 through the view -> Option A
  4. Quick Check:

    WHERE clause allows updates on visible rows [OK]
Quick Trick: WHERE filters rows but allows updates on visible ones [OK]
Common Mistakes:
MISTAKES
  • Thinking WHERE blocks all updates
  • Assuming inserts ignore WHERE condition
  • Believing deletes affect all table rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes