Bird
0
0

You wrote this SQL to create a view:

medium📝 Debug Q7 of 15
SQL - Views
You wrote this SQL to create a view:

CREATE VIEW UserEmails AS SELECT user_id, email FROM Users;

Later, you try to update the Users table's email column but get an error when using the view. Why?
AThe view does not include the primary key
BViews are read-only by default and may not allow updates
CYou cannot update columns named email
DThe view must be dropped before updating the table
Step-by-Step Solution
Solution:
  1. Step 1: Understand view update limitations

    Many views are read-only and do not allow direct updates to underlying tables.
  2. Step 2: Check the view definition

    This view selects user_id and email, but updates through views depend on database rules.
  3. Final Answer:

    Views are read-only by default and may not allow updates -> Option B
  4. Quick Check:

    Views often read-only = update errors [OK]
Quick Trick: Views often block updates unless explicitly allowed [OK]
Common Mistakes:
MISTAKES
  • Thinking views always allow updates
  • Believing primary key absence causes update error
  • Assuming column names restrict updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes