DROP VIEW
Overview
The DROP VIEW
statement removes an existing view from the database. Once a view is dropped, it can no longer be referenced in queries unless it is recreated.
Syntax
DROP VIEW [IF EXISTS] schema_name.view_name;
Parameters
- IF EXISTS – Optional clause that prevents an error if the view does not exist.
- schema_name – The schema that contains the view (default is
dbo
). - view_name – The name of the view to drop.
Example
Suppose you have a view named EmployeeSummary
in the dbo
schema.
-- Drop the view if it exists DROP VIEW IF EXISTS dbo.EmployeeSummary;
What Happens After DROP?
The view definition is removed, but the underlying tables remain unchanged. Any dependent objects (e.g., stored procedures) that reference the view will become invalid until they are altered or the view is recreated.