-
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
24122dd
Added doc
shivusondur a1fb4cf
ADDED THE VIEW DOC
shivusondur 3b4252e
Updated the document details
shivusondur 42cda3e
Updated the document details
shivusondur 5683d95
Updated the document according to latest comments
shivusondur 4ee7a76
Updated the document according to latest comments
shivusondur c171040
Updated the document according to latest comments
shivusondur 194a0b0
Handled the dilipbiswal's comments
shivusondur df23c95
handled the comments
shivusondur 2ca9a6e
handled the comments
shivusondur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,69 @@ 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 an exception. | ||
|
|
||
| In case of External table, only the associated metadata information are removed from the metastore database. | ||
|
||
|
|
||
| ### 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> | ||
| Specifies the database name where table is present. | ||
| </dd> | ||
| <dt><code><em>table_name</em></code></dt> | ||
| <dd> | ||
| Specifies the 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) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,63 @@ license: | | |
| limitations under the License. | ||
| --- | ||
|
|
||
| **This page is under construction** | ||
| ### Description | ||
| DROP VIEW removes the metadata associated with a specified view from the catalog. | ||
shivusondur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### 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> | ||
| Specifies the database name where view is present. | ||
| </dd> | ||
| <dt><code><em>view_name</em></code></dt> | ||
| <dd> | ||
| Specifies the 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) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.