DROP VIEWDROP VIEW
從目錄中移除與指定之 view 相關聯的中繼資料。Removes the metadata associated with a specified view from the catalog.
SyntaxSyntax
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;