-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28810][DOC][SQL] Document SHOW TABLES in SQL Reference. #25561
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 10 commits
77e753a
5178160
19f39fc
55ea2cf
0dd4efb
1d08b22
847fb8e
05a2e60
fed9431
83cff5d
f3e1c31
8e1e114
e26f55b
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 |
|---|---|---|
|
|
@@ -18,5 +18,89 @@ license: | | |
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --- | ||
| ### Description | ||
|
|
||
| **This page is under construction** | ||
| The `SHOW TABLES` statement returns all the tables for an optionally specified database. | ||
| Additionally, the output of this statement may be filtered by an optional matching | ||
| pattern. If no database is specified then the tables are returned from the | ||
| current database. | ||
|
|
||
| ### Syntax | ||
| {% highlight sql %} | ||
| SHOW TABLES [{FROM|IN} database_name] [LIKE 'regex_pattern'] | ||
| {% endhighlight %} | ||
|
|
||
| ### Parameters | ||
| <dl> | ||
| <dt><code><em>{FROM|IN} database_name</em></code></dt> | ||
| <dd> | ||
| Specifies the `database` name from which tables are listed. | ||
| </dd> | ||
| <dt><code><em>LIKE 'regex_pattern'</em></code></dt> | ||
| <dd> | ||
| Specifies the regular expression pattern that is used to filter out unwanted tables. | ||
| <ul> | ||
| <li> Except `*` and `|` characters remaining characters will follow the regular expression convention.</li> | ||
| <li> `*` matches 0 or more characters and `|` used to provide more than one regex with OR condition. </li> | ||
|
||
| <li> The leading and trailing blanks are trimmed in the input pattern before processing.</li> | ||
| </ul> | ||
|
|
||
| </dd> | ||
| </dl> | ||
|
|
||
| ### Example | ||
| {% highlight sql %} | ||
| -- List all tables in default database | ||
| SHOW TABLES; | ||
| +-----------+------------+--------------+--+ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please lets fix the formatting. Did we construct this output by hand ? Can we paste the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dilipbiswal In the UI it looks like below, i think it is normal Only in the git file editor, it shows inconsistent. |
||
| | database | tableName | isTemporary | | ||
| +-----------+------------+--------------+--+ | ||
| | default | sam | false | | ||
| | default | sam1 | false | | ||
| | default | suj | false | | ||
| +-----------+------------+--------------+--+ | ||
|
|
||
| -- List all tables from userdb database | ||
| SHOW TABLES FROM userdb; | ||
| +-----------+------------+--------------+--+ | ||
| | database | tableName | isTemporary | | ||
| +-----------+------------+--------------+--+ | ||
| | userdb | user1 | false | | ||
| | userdb | user2 | false | | ||
| +-----------+------------+--------------+--+ | ||
|
|
||
| -- List all tables in userdb database | ||
| SHOW TABLES IN userdb; | ||
| +-----------+------------+--------------+--+ | ||
| | database | tableName | isTemporary | | ||
| +-----------+------------+--------------+--+ | ||
| | userdb | user1 | false | | ||
| | userdb | user2 | false | | ||
| +-----------+------------+--------------+--+ | ||
|
|
||
| -- List all tables from default database matching the pattern `sam*` | ||
| SHOW TABLES FROM default LIKE 'sam*'; | ||
| +-----------+------------+--------------+--+ | ||
| | database | tableName | isTemporary | | ||
| +-----------+------------+--------------+--+ | ||
| | default | sam | false | | ||
| | default | sam1 | false | | ||
| +-----------+------------+--------------+--+ | ||
|
|
||
| -- List all tables matching the pattern `sam*|suj` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: can we have a line between previous test and this one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dilipbiswal |
||
| SHOW TABLES LIKE 'sam*|suj'; | ||
| +-----------+------------+--------------+--+ | ||
| | database | tableName | isTemporary | | ||
| +-----------+------------+--------------+--+ | ||
| | default | sam | false | | ||
| | default | sam1 | false | | ||
| | default | suj | false | | ||
| +-----------+------------+--------------+--+ | ||
|
|
||
| {% endhighlight %} | ||
shivusondur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Related statements | ||
| - [CREATE TABLE](sql-ref-syntax-ddl-create-table.html) | ||
| - [DROP TABLE](sql-ref-syntax-ddl-drop-table.html) | ||
| - [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html) | ||
| - [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html) | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Except for
*and|, the pattern works like a regex"