DROP VIEW
适用于: Databricks SQL Databricks Runtime
从目录中删除与指定视图关联的元数据。 若要删除某个视图,你必须是该视图的所有者,或者是该视图所在的架构、目录或元存储的所有者。
语法
DROP [ MATERIALIZED ] VIEW [ IF EXISTS ] view_name
参数
IF EXISTS
如果已指定,则当视图不存在时,不会引发 TABLE_OR_VIEW_NOT_FOUND 错误。
-
要删除的视图的名称。 如果找不到视图,Azure Databricks 会引发 TABLE_OR_VIEW_NOT_FOUND 错误。
示例
-- Assumes a view named `employeeView` exists.
> DROP VIEW employeeView;
-- Assumes a view named `employeeView` exists in the `usersc` schema
> DROP VIEW usersc.employeeView;
-- Assumes a view named `employeeView` does not exist.
-- Throws TABLE_OR_VIEW_NOT_FOUND
> DROP VIEW employeeView;
[TABLE_OR_VIEW_NOT_FOUND]
-- Assumes a materialized view named `employeeView` exists.
> DROP MATERIALIZED VIEW employeeView
-- Assumes a view named `employeeView` does not exist. Try with IF EXISTS
-- this time it will not throw exception
> DROP VIEW IF EXISTS employeeView;