Bird
0
0

Which SQL syntax correctly creates a simple updatable view on a single table employees showing id and name?

easy📝 Syntax Q12 of 15
SQL - Views
Which SQL syntax correctly creates a simple updatable view on a single table employees showing id and name?
ACREATE VIEW emp_view AS SELECT id, name FROM employees GROUP BY id;
BCREATE VIEW emp_view AS SELECT id, name, COUNT(*) FROM employees;
CCREATE VIEW emp_view AS SELECT id, name FROM employees;
DCREATE VIEW emp_view AS SELECT id, name FROM employees JOIN departments ON employees.dept_id = departments.id;
Step-by-Step Solution
Solution:
  1. Step 1: Identify simple view syntax

    CREATE VIEW emp_view AS SELECT id, name FROM employees; selects columns directly from one table without grouping or joins, which is valid for an updatable view.
  2. Step 2: Check other options for complexity

    Options A and C use GROUP BY or aggregate functions, making views non-updatable. CREATE VIEW emp_view AS SELECT id, name FROM employees JOIN departments ON employees.dept_id = departments.id; uses JOIN, also usually non-updatable.
  3. Final Answer:

    CREATE VIEW emp_view AS SELECT id, name FROM employees; -> Option C
  4. Quick Check:

    Simple select from one table = updatable view syntax [OK]
Quick Trick: Simple SELECT without joins or aggregates creates updatable views [OK]
Common Mistakes:
MISTAKES
  • Adding GROUP BY or aggregates in view
  • Using JOINs in view definition
  • Forgetting to select from only one table

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes