Recall & Review
beginner
What does the SQL command
DROP VIEW do?It removes an existing view from the database permanently. After dropping, the view no longer exists and cannot be queried.
Click to reveal answer
beginner
How do you change the structure or definition of an existing view in SQL?
You use the
CREATE OR REPLACE VIEW statement with the new definition. This updates the view without dropping it first.Click to reveal answer
intermediate
True or False: You can use
ALTER VIEW to modify a view's SELECT statement in all SQL databases.False. Not all SQL databases support
ALTER VIEW. Many require dropping and recreating the view or using CREATE OR REPLACE VIEW.Click to reveal answer
beginner
What happens if you try to drop a view that does not exist using
DROP VIEW view_name;?The database will return an error unless you use
DROP VIEW IF EXISTS view_name; which avoids errors if the view is missing.Click to reveal answer
intermediate
Why might you prefer
CREATE OR REPLACE VIEW over dropping and recreating a view?Because it keeps permissions and dependencies intact and avoids errors if the view is referenced elsewhere in the database.
Click to reveal answer
Which SQL command removes a view permanently?
✗ Incorrect
DROP VIEW deletes the view permanently from the database.
How do you update the SELECT query of an existing view without dropping it first?
✗ Incorrect
CREATE OR REPLACE VIEW updates the view's definition safely.
What does
DROP VIEW IF EXISTS view_name; do?✗ Incorrect
This command safely drops a view only if it exists.
Which statement is true about
ALTER VIEW?✗ Incorrect
Support for ALTER VIEW varies; many use CREATE OR REPLACE VIEW instead.
Why is
CREATE OR REPLACE VIEW often preferred over dropping and recreating a view?✗ Incorrect
This method preserves permissions and avoids breaking dependencies.
Explain how to safely update the definition of an existing view in SQL.
Think about commands that replace without deleting.
You got /3 concepts.
Describe what happens when you drop a view and why you might want to use IF EXISTS.
Consider error handling when the view might not be there.
You got /3 concepts.