13.1.35 DROP VIEW Statement语句

DROP VIEW [IF EXISTS]
view_name [, view_name] ...
    [RESTRICT | CASCADE]

DROP VIEW removes one or more views. DROP VIEW删除一个或多个视图。You must have the DROP privilege for each view.您必须具有每个视图的DROP权限。

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.如果参数列表中命名的任何视图不存在,则语句将失败,并出现一个错误,通过名称指示无法删除的不存在视图,并且不会进行任何更改。

Note注意

In MySQL 5.7 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. 在MySQL 5.7及更早版本中,如果参数列表中的任何视图不存在,DROP VIEW会返回一个错误,但也会删除列表中确实存在的所有视图。Due to the change in behavior in MySQL 8.0, a partially completed DROP VIEW operation on a MySQL 5.7 replication source server fails when replicated on a MySQL 8.0 replica. 由于MySQL 8.0中的行为改变,在MySQL 5.7复制源服务器上复制时,部分完成的DROP VIEW操作会失败。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. 若要避免此故障场景,请在DROP VIEW语句中使用IF EXISTS语法,以防止不存在的视图发生错误。For more information, see Section 13.1.1, “Atomic Data Definition Statement Support”.有关更多信息,请参阅第13.1.1节,“原子数据定义语句支持”

The IF EXISTS clause prevents an error from occurring for views that don't exist. IF EXISTS子句防止不存在的视图发生错误。When this clause is given, a NOTE is generated for each nonexistent view. 给出此子句后,将为每个不存在的视图生成NOTESee Section 13.7.7.42, “SHOW WARNINGS Statement”.请参阅第13.7.7.42节,“显示警告声明”

RESTRICT and CASCADE, if given, are parsed and ignored.RESTRICTCASCADE(如果给定)将被解析和忽略。