適用於:
Databricks SQL
Databricks Runtime
從目錄移除與指定檢視相關聯的元數據。
若要卸除檢視,您必須擁有該檢視的 MANAGE 許可權,或必須是該檢視、架構、目錄或中繼存放區的擁有者。
語法
DROP [ MATERIALIZED ] VIEW [ IF EXISTS ] view_name
參數
如果存在
如果指定,當檢視不存在時,不會 擲回任何TABLE_OR_VIEW_NOT_FOUND 錯誤。
-
要刪除的檢視名稱。 如果找不到檢視,Azure Databricks 就會 引發TABLE_OR_VIEW_NOT_FOUND 錯誤。 如果找到的關聯不是檢視,Azure Databricks 會引發 WRONG_COMMAND_FOR_OBJECT_TYPE 錯誤。
範例
-- 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;