Bird
0
0

You have a view defined as:

medium📝 Debug Q6 of 15
SQL - Views
You have a view defined as:
CREATE VIEW product_prices AS SELECT DISTINCT product_id, price FROM products;

Which of the following queries will cause an error when run on this view?
AUPDATE product_prices SET price = price * 1.1 WHERE product_id = 5;
BSELECT * FROM product_prices;
CSELECT product_id, price FROM product_prices WHERE price > 100;
DSELECT price FROM product_prices WHERE product_id = 10;
Step-by-Step Solution
Solution:
  1. Step 1: Recall that views are virtual tables

    Most views are read-only unless explicitly made updatable.
  2. Step 2: Identify which query tries to modify data

    UPDATE product_prices SET price = price * 1.1 WHERE product_id = 5; tries to UPDATE the view, which will cause an error if the view is not updatable.
  3. Final Answer:

    UPDATE product_prices SET price = price * 1.1 WHERE product_id = 5; -> Option A
  4. Quick Check:

    Updating a view causes error unless updatable [OK]
Quick Trick: Views are usually read-only; updates often fail [OK]
Common Mistakes:
MISTAKES
  • Trying to update a view without updatable support
  • Confusing SELECT with UPDATE
  • Assuming all views allow data changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes