Purpose
You can use this statement to drop one or more views.
Notice
To execute this statement, you must have the DROP privilege for each view.
Syntax
drop_view_stmt:
DROP VIEW [IF EXISTS] view_name_list [CASCADE | RESTRICT];
view_name_list:
view_name [, view_name_list]
Parameters
| Parameter | Description |
|---|---|
| IF EXISTS | The IF EXISTS keyword prevents the error that occurs because the view to be dropped does not exist. |
| view_name_list | If view_name_list contains views that do not exist, an error may be reported during execution but the specified views that exist are dropped. |
| CASCADE | RESTRICT | CASCADE specifies that the objects dependent on the view are automatically dropped. RESTRICT specifies that the view cannot be dropped if an object that depends on the view exists. Note: The current version does not support this parameter. If this parameter is specified, it will be parsed and ignored. |
Examples
Drop the
v1view.obclient> DROP VIEW v1; Query OK, 0 rows affected (0.02 sec)Drop the
v1andv2views.obclient> DROP VIEW IF EXISTS v1,v2; Query OK, 0 rows affected, 1 warning (0.01 sec)Drop multiple views without specifying
IF EXISTS. If a view does not exist, an error is returned.obclient> DROP VIEW v1,v2; ERROR 1051 (42S02): Unknown table 'test.v1'