DROP VIEW [IF EXISTS]
view_name [, view_name] ...
[RESTRICT | CASCADE]
DROP VIEW 用于删除一个或多个视图。必须对每个视图拥有 DROP 权限。DROP VIEW removes one or more
views. You must have the DROP
privilege for each view.
如果参数列表中指定的任何视图不存在,该语句将失败并显示错误,指明未能删除的不存在视图的名称,并且不会进行任何更改。If any views named in the argument list do not exist, the statement fails with an error indicating by name which nonexisting views it was unable to drop, and no changes are made.
在 MySQL 8.3 及更早版本中,DROP VIEW参数列表中没有任何显示的视图,会返回错误,但也会丢弃列表中所有存在的视图。由于 MySQL 8.4 的行为变化,部分完成的 DROP VIEW 操作在 MySQL 8.4 副本上复制时失败。为避免此故障,请使用 IF EXISTS语法在 DROP VIEW 语句,以防止不存在的视图发生错误。更多信息请参见 第 15.1.1 节,”原子数据定义语句支持“。In MySQL 8.3 and earlier,
DROP VIEW returns an error if any
views named in the argument list do not exist, but also drops
all views in the list that do exist. Due to the change in
behavior in MySQL 8.4, a partially completed
DROP VIEW operation on a MySQL
8.3 replication source server fails when
replicated on a MySQL 8.4 replica. To avoid this
failure scenario, use IF EXISTS syntax in
DROP VIEW statements to prevent
an error from occurring for views that do not exist. For more
information, see Section 15.1.1, “Atomic Data Definition Statement Support”.
IF EXISTS子句防止不存在的视图发生错误。当给出该子句时,每个不存在的视图都会生成一个NOTE。参见 第 15.7.7.42 节,“SHOW WARNINGS Statement”。The IF EXISTS clause prevents an error from
occurring for views that don't exist. When this clause is given, a
NOTE is generated for each nonexistent view.
See Section 15.7.7.42, “SHOW WARNINGS Statement”.
RESTRICT 和 CASCADE,如果给出,则解析并忽略。RESTRICT and CASCADE, if
given, are parsed and ignored.