DROP VIEW statement

Use this statement to remove a view from the database.

Syntax
DROP VIEW [ IF EXISTS ] [ owner.]view-name
Remarks

Use the IF EXISTS clause if you do not want an error returned when the DROP VIEW statement attempts to remove a view that does not exist.

When you execute the DROP VIEW statement, the status of all dependent regular views change to INVALID. To determine view dependencies before dropping a view, use the sa_dependent_views system procedure. See sa_dependent_views system procedure.

Permissions

Any user who owns the object, or has DBA authority, can execute the DROP VIEW statement.

Side effects

Automatic commit. Clears the Results tab in the Results pane in Interactive SQL. Executing a DROP VIEW statement closes all cursors for the current connection.

When a view is dropped, all procedures and triggers are unloaded from memory, so that any procedure or trigger that references the view reflects the fact that the view does not exist. The unloading and loading of procedures and triggers can affect performance if you are regularly dropping and creating views.

See also
Standards and compatibility
  • SQL/2003   Core feature.

Example

Drop MyView from the database. If the view does not exist, an error is returned.

DROP VIEW MyView;