删除视图
描述
DROP VIEW
从目录中删除与指定视图关联的元数据。
语法
DROP VIEW [ IF EXISTS ] view_identifier
参数
-
IF EXISTS
如果指定,则在视图不存在时不会引发异常。
-
view_identifier
指定要删除的视图名称。视图名称可以选择使用数据库名称进行限定。
语法:
[ 数据库名称. ] 视图名称
示例
-- 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;