Skip to main content

DROP VIEW

Description

This statement is used to drop one or more views.

Limitations and Considerations

When dropping multiple views, the current user must have the DROP permission on each view.

Permissions

To execute the DROP VIEW statement, the current user must have the DROP permission. For more information about seekdb permissions, see seekdb permission types.

Syntax

DROP VIEW [IF EXISTS] view_name_list [CASCADE | RESTRICT];

view_name_list:
view_name [, view_name ...]

Parameters

ParameterDescription
IF EXISTSOptional. If this parameter is specified, the drop operation is performed only if the view exists. If the view does not exist, the operation is ignored.
view_name_listThe list of view names to be dropped. You can drop one or more views. If view_name_list contains both existing and non-existing views, an error may be returned, but the existing views will still be dropped.
view_nameThe name of the view.
CASCADE | RESTRICTOptional. Specifies the drop option. Valid values:
  • CASCADE: Drops the view and all dependent objects.
  • RESTRICT: Drops the view only if there are no dependent objects.
:::tip The current version only supports the syntax of the drop option, but the feature is not effective. :::

Examples

  • Drop the view v1.

    DROP VIEW v1;
  • Drop the views v2 and v3.

    DROP VIEW IF EXISTS v2, v3;
  • Drop the views without using IF EXISTS. If any of the views do not exist, an error will be returned.

    DROP VIEW v1, v4;

    The return result is as follows:

    ERROR 1051 (42S02): Unknown table 'test.v1'

References