SQL Keywords

SQL DROP VIEW

What does the SQL DROP VIEW statement do?

Removes one or more existing views from the database catalog.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL DROP VIEW: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, BigQuery, Redshift

SQL DROP VIEW Full Explanation

SQL DROP VIEW is a Data Definition Language (DDL) command that permanently deletes a view definition from the system catalog. After execution, the view can no longer be queried, granted permissions, or referenced by other database objects. Most dialects let you add IF EXISTS to avoid errors when the target view is missing, and CASCADE or RESTRICT to control what happens if other objects depend on the view. Dropping a view does not affect the underlying base tables; only the stored SELECT statement and its metadata are removed.

SQL DROP VIEW Syntax

DROP VIEW [IF EXISTS] view_name [, view_name_2 ...] [CASCADE | RESTRICT];

SQL DROP VIEW Parameters

  • view_name (identifier) - Name of the view to drop.
  • IF EXISTS (keyword) - Suppress error if the view does not exist.
  • CASCADE (keyword) - Automatically drop dependent objects (other views, grants, etc.).
  • RESTRICT (keyword) - Refuse to drop if dependent objects exist (default in many systems).

Example Queries Using SQL DROP VIEW

-- Drop a single view if it exists
DROP VIEW IF EXISTS sales_summary;

-- Drop multiple views at once
DROP VIEW quarterly_stats, yearly_stats;

-- Drop a view and any objects that reference it
DROP VIEW customer_rollup CASCADE;

Expected Output Using SQL DROP VIEW

  • The specified view definitions are removed from the catalog
  • Subsequent queries that reference those views will fail with an object-not-found error

Use Cases with SQL DROP VIEW

  • Clean up obsolete or temporary reporting views.
  • Replace a view with a new definition (drop, then create).
  • Remove a view before dropping the underlying tables.
  • Automate schema migrations where views change between versions.

Common Mistakes with SQL DROP VIEW

  • Forgetting IF EXISTS and receiving an error when the view is absent.
  • Using RESTRICT (implicit default) when dependencies exist, causing the statement to fail.
  • Confusing DROP VIEW with DELETE, which removes data, not schema objects.
  • Attempting to drop a materialized view with DROP VIEW instead of DROP MATERIALIZED VIEW.

Related Topics

CREATE VIEW, ALTER VIEW, DROP TABLE, DROP MATERIALIZED VIEW, CREATE OR REPLACE VIEW

First Introduced In

SQL-92

Frequently Asked Questions

What happens if the view does not exist?

Add IF EXISTS to avoid an error. The database returns a notice and continues executing the batch.

How do I drop multiple views at once?

List them comma-separated in a single DROP VIEW statement: `DROP VIEW v1, v2, v3;`.

Is DROP VIEW reversible?

Not after the transaction commits. You must recreate the view or restore from backup.

Does DROP VIEW affect the underlying tables?

No. The command deletes only the view definition; base tables and their data remain intact.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!