Bird
0
0

You have a view defined as:

medium📝 Debug Q14 of 15
SQL - Views
You have a view defined as:
CREATE VIEW emp_dept AS SELECT e.id, e.name, d.name AS dept_name FROM employees e JOIN departments d ON e.dept_id = d.id;

Attempting to update dept_name through this view causes an error. What is the main reason?
AViews with JOINs are not updatable by default.
BYou cannot update columns with aliases in views.
CThe view lacks a WHERE clause to filter rows.
DThe view must include all columns from both tables to be updatable.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the view's structure

    The view uses a JOIN between employees and departments tables.
  2. Step 2: Recall update limitations on joined views

    Views involving JOINs are generally not updatable because the database cannot determine which table to update.
  3. Final Answer:

    Views with JOINs are not updatable by default. -> Option A
  4. Quick Check:

    JOIN views block updates unless special rules apply [OK]
Quick Trick: JOINs in views block updates by default [OK]
Common Mistakes:
MISTAKES
  • Thinking alias columns block updates
  • Believing WHERE clause affects updatability
  • Assuming all columns must be selected

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes