Purpose
You can use this statement to drop one or more views.
Notice
To execute this statement, you must have the
DROPprivilege on 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 a 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 indicates that the objects dependent on the view are automatically removed. RESTRICT indicates that the view cannot be dropped if an object dependent 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 views
v1andv2.obclient> DROP VIEW IF EXISTS v1,v2; Query OK, 0 rows affected, 1 warning (0.01 sec)
Drop multiple views without using the
IF EXISTSclause. If a view does not exist, an error is returned.obclient> DROP VIEW v1,v2; ERROR 1051 (42S02): Unknown table 'test.v1'