@@ -20,33 +20,63 @@ license: |
2020---
2121
2222### Description
23- Removes the view , which was created by CREATE VIEW statement. DROP VIEW only involves
24- changes in metadata in the metastore database.
23+ Drops the specified ` VIEW ` , which was created by ` CREATE VIEW ` statement. ` DROP VIEW ` only involves
24+ changes in metadata from the metastore database.
2525
2626### Syntax
2727{% highlight sql %}
28- DROP VIEW [ IF EXISTS] [ dbname. ] viewName
28+ DROP VIEW [ IF EXISTS] [ database_name. ] view_name
2929{% endhighlight %}
3030
3131### Parameter
32+ <dl >
33+ <dt ><code ><em >IF EXISTS</em ></code ></dt >
34+ <dd >
35+ If specified, no exception is thrown when the view does not exist.
36+ </dd >
37+ <dt ><code ><em >database_name</em ></code ></dt >
38+ <dd >
39+ Database name where view is present.
40+ </dd >
41+ <dt ><code ><em >view_name</em ></code ></dt >
42+ <dd >
43+ view name to be dropped.
44+ </dd >
45+ </dl >
3246
33- ** dbname**
34-
35- * Database* name where view present, if not provided it takes the * current Database* .
36-
37- ** viewName**
47+ ### Example
48+ {% highlight sql %}
49+ -- Assumes a view name ` employeeView ` exist.
50+ DROP VIEW employeeView;
51+ +---------+--+
52+ | Result |
53+ +---------+--+
54+ +---------+--+
3855
39- * View* to be dropped
56+ -- Assumes a view name ` employeeView ` exist in ` userdb ` database
57+ DROP VIEW userdb.employeeView;
58+ +---------+--+
59+ | Result |
60+ +---------+--+
61+ +---------+--+
4062
41- ** IF EXISTS**
63+ -- Assumes a view name ` employeeView ` does not exist.
64+ -- Throws exception
65+ DROP VIEW employeeView;
66+ Error: org.apache.spark.sql.AnalysisException: Table or view not found: employeeView;
67+ (state=,code=0)
4268
43- If specified will not throw exception if * view* is not present.
69+ -- Assumes a view name ` employeeView ` does not exist,Try with IF EXISTS
70+ -- this time it will not throw exception
71+ DROP VIEW IF EXISTS employeeView;
72+ +---------+--+
73+ | Result |
74+ +---------+--+
75+ +---------+--+
4476
45- ### Example
46- {% highlight sql %}
47- DROP VIEW USERDB.USERVIEW
48- DROP TABLE USERVIEW
49- DROP VIEW IF EXISTS USERDB.USERVIEW
50- DROP VIEW IF EXISTS USERVIEW
5177{% endhighlight %}
5278
79+ ### Related Statements
80+ - [ CREATE VIEW ] ( sql-ref-syntax-ddl-create-view.html )
81+ - [ CREATE DATABASE] ( sql-ref-syntax-ddl-create-database.html )
82+ - [ DROP DATABASE] ( sql-ref-syntax-ddl-drop-database.html )
0 commit comments