-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28798][DOC][SQL]Document DROP TABLE/VIEW statement in SQL Reference. #25533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
24122dd
a1fb4cf
3b4252e
42cda3e
5683d95
4ee7a76
c171040
194a0b0
df23c95
2ca9a6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,70 @@ license: | | |
| limitations under the License. | ||
| --- | ||
|
|
||
| **This page is under construction** | ||
| ### Description | ||
|
|
||
| Deletes the table and removes the directory associated with this table from the file system | ||
| if this is not `EXTERNAL` table. If the table is not present it throws exception. | ||
|
||
|
|
||
| In case of External table it only deletes the metadata from metastore database and it will not remove the directory | ||
|
||
| associated with this table. | ||
|
|
||
| ### Syntax | ||
| {% highlight sql %} | ||
| DROP TABLE [IF EXISTS] [database_name.]table_name | ||
| {% endhighlight %} | ||
|
|
||
| ### Parameter | ||
| <dl> | ||
| <dt><code><em>IF EXISTS</em></code></dt> | ||
| <dd> | ||
| If specified, no exception is thrown when the table does not exist. | ||
| </dd> | ||
| <dt><code><em>database_name</em></code></dt> | ||
| <dd> | ||
| Database name where table is present. | ||
|
||
| </dd> | ||
| <dt><code><em>table_name</em></code></dt> | ||
| <dd> | ||
| table name to be dropped. | ||
|
||
| </dd> | ||
| </dl> | ||
|
|
||
| ### Example | ||
| {% highlight sql %} | ||
| -- Assumes a table name `employeetable` exist. | ||
| DROP TABLE employeetable; | ||
| +---------+--+ | ||
| | Result | | ||
shivusondur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| +---------+--+ | ||
| +---------+--+ | ||
|
|
||
| -- Assumes a table name `employeetable` exist in `userdb` database | ||
| DROP TABLE userdb.employeetable; | ||
| +---------+--+ | ||
| | Result | | ||
| +---------+--+ | ||
| +---------+--+ | ||
|
|
||
| -- Assumes a table name `employeetable` does not exist. | ||
| -- Throws exception | ||
| DROP TABLE employeetable; | ||
| Error: org.apache.spark.sql.AnalysisException: Table or view not found: employeetable; | ||
| (state=,code=0) | ||
|
|
||
| -- Assumes a table name `employeetable` does not exist,Try with IF EXISTS | ||
| -- this time it will not throw exception | ||
| DROP TABLE IF EXISTS employeetable; | ||
| +---------+--+ | ||
| | Result | | ||
| +---------+--+ | ||
| +---------+--+ | ||
|
|
||
| {% endhighlight %} | ||
|
|
||
| ### Related Statements | ||
| - [CREATE TABLE ](sql-ref-syntax-ddl-create-table.html) | ||
| - [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html) | ||
| - [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,64 @@ license: | | |
| limitations under the License. | ||
| --- | ||
|
|
||
| **This page is under construction** | ||
| ### Description | ||
| Drops the specified `VIEW`, which was created by `CREATE VIEW` statement. `DROP VIEW` only involves | ||
|
||
| changes in metadata from the metastore database. | ||
|
|
||
| ### Syntax | ||
| {% highlight sql %} | ||
| DROP VIEW [IF EXISTS] [database_name.]view_name | ||
| {% endhighlight %} | ||
|
|
||
| ### Parameter | ||
| <dl> | ||
| <dt><code><em>IF EXISTS</em></code></dt> | ||
| <dd> | ||
| If specified, no exception is thrown when the view does not exist. | ||
| </dd> | ||
| <dt><code><em>database_name</em></code></dt> | ||
| <dd> | ||
| Database name where view is present. | ||
|
||
| </dd> | ||
| <dt><code><em>view_name</em></code></dt> | ||
| <dd> | ||
| view name to be dropped. | ||
| </dd> | ||
| </dl> | ||
|
|
||
| ### Example | ||
| {% highlight sql %} | ||
| -- Assumes a view name `employeeView` exist. | ||
|
||
| DROP VIEW employeeView; | ||
| +---------+--+ | ||
| | Result | | ||
| +---------+--+ | ||
| +---------+--+ | ||
|
|
||
| -- Assumes a view name `employeeView` exist in `userdb` database | ||
shivusondur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| DROP VIEW userdb.employeeView; | ||
| +---------+--+ | ||
| | Result | | ||
| +---------+--+ | ||
| +---------+--+ | ||
|
|
||
| -- Assumes a view name `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 name `employeeView` does not exist,Try with IF EXISTS | ||
| -- this time it will not throw exception | ||
| DROP VIEW IF EXISTS employeeView; | ||
| +---------+--+ | ||
| | Result | | ||
| +---------+--+ | ||
| +---------+--+ | ||
|
|
||
| {% endhighlight %} | ||
|
|
||
| ### Related Statements | ||
| - [CREATE VIEW ](sql-ref-syntax-ddl-create-view.html) | ||
shivusondur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html) | ||
| - [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html) | ||
Uh oh!
There was an error while loading. Please reload this page.