0001 ---
0002 layout: global
0003 title: DROP VIEW
0004 displayTitle: DROP VIEW
0005 license: |
0006 Licensed to the Apache Software Foundation (ASF) under one or more
0007 contributor license agreements. See the NOTICE file distributed with
0008 this work for additional information regarding copyright ownership.
0009 The ASF licenses this file to You under the Apache License, Version 2.0
0010 (the "License"); you may not use this file except in compliance with
0011 the License. You may obtain a copy of the License at
0012
0013 http://www.apache.org/licenses/LICENSE-2.0
0014
0015 Unless required by applicable law or agreed to in writing, software
0016 distributed under the License is distributed on an "AS IS" BASIS,
0017 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018 See the License for the specific language governing permissions and
0019 limitations under the License.
0020 ---
0021
0022 ### Description
0023
0024 `DROP VIEW` removes the metadata associated with a specified view from the catalog.
0025
0026 ### Syntax
0027
0028 ```sql
0029 DROP VIEW [ IF EXISTS ] view_identifier
0030 ```
0031
0032 ### Parameter
0033
0034 * **IF EXISTS**
0035
0036 If specified, no exception is thrown when the view does not exist.
0037
0038 * **view_identifier**
0039
0040 Specifies the view name to be dropped. The view name may be optionally qualified with a database name.
0041
0042 **Syntax:** `[ database_name. ] view_name`
0043
0044 ### Examples
0045
0046 ```sql
0047 -- Assumes a view named `employeeView` exists.
0048 DROP VIEW employeeView;
0049
0050 -- Assumes a view named `employeeView` exists in the `userdb` database
0051 DROP VIEW userdb.employeeView;
0052
0053 -- Assumes a view named `employeeView` does not exist.
0054 -- Throws exception
0055 DROP VIEW employeeView;
0056 Error: org.apache.spark.sql.AnalysisException: Table or view not found: employeeView;
0057 (state=,code=0)
0058
0059 -- Assumes a view named `employeeView` does not exist,Try with IF EXISTS
0060 -- this time it will not throw exception
0061 DROP VIEW IF EXISTS employeeView;
0062 ```
0063
0064 ### Related Statements
0065
0066 * [CREATE VIEW](sql-ref-syntax-ddl-create-view.html)
0067 * [ALTER VIEW](sql-ref-syntax-ddl-alter-view.html)
0068 * [SHOW VIEWS](sql-ref-syntax-aux-show-views.html)
0069 * [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html)
0070 * [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html)