Bird
0
0

Given a view active_customers defined as SELECT * FROM customers WHERE status = 'active', what will be the result after running ALTER VIEW active_customers AS SELECT * FROM customers WHERE status = 'inactive'; and then querying SELECT * FROM active_customers;?

medium📝 query result Q13 of 15
SQL - Views
Given a view active_customers defined as SELECT * FROM customers WHERE status = 'active', what will be the result after running ALTER VIEW active_customers AS SELECT * FROM customers WHERE status = 'inactive'; and then querying SELECT * FROM active_customers;?
AIt will return all customers with status 'inactive'.
BIt will cause a syntax error.
CIt will return all customers regardless of status.
DIt will return all customers with status 'active'.
Step-by-Step Solution
Solution:
  1. Step 1: Understand ALTER VIEW effect

    The ALTER VIEW command changes the query inside the view to the new SELECT statement.
  2. Step 2: Analyze the new query

    The view now selects customers where status = 'inactive'. So querying the view returns inactive customers.
  3. Final Answer:

    It will return all customers with status 'inactive'. -> Option A
  4. Quick Check:

    ALTER VIEW changes the view's query [OK]
Quick Trick: ALTER VIEW changes the query; output matches new SELECT [OK]
Common Mistakes:
MISTAKES
  • Assuming view still returns old data after ALTER
  • Thinking ALTER VIEW causes errors if view exists
  • Confusing view data with table data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes