DROP VIEWDROP VIEW
从目录中删除与指定视图关联的元数据。Removes the metadata associated with a specified view from the catalog.
语法Syntax
DROP VIEW [ IF EXISTS ] view_identifier
参数Parameter
IF EXISTSIF EXISTS
如果已指定,则在视图不存在时不会引发异常。If specified, no exception is thrown when the view does not exist.
view_identifierview_identifier
要删除的视图名称。The view name to be dropped. 视图名称可以有选择性地使用数据库名称进行限定。The view name may be optionally qualified with a database name.
语法:
[database_name.] view_name
Syntax:[database_name.] view_name
示例Examples
-- Assumes a view named `employeeView` exists.
DROP VIEW employeeView;
-- Assumes a view named `employeeView` exists in the `userdb` database
DROP VIEW userdb.employeeView;
-- Assumes a view named `employeeView` does not exist.
-- Throws exception
DROP VIEW employeeView;
Error: org.apache.spark.sql.AnalysisException: Table or view not found: employeeView;
(state=,code=0)
-- Assumes a view named `employeeView` does not exist,Try with IF EXISTS
-- this time it will not throw exception
DROP VIEW IF EXISTS employeeView;