0001 ---
0002 layout: global
0003 title: SHOW TABLES
0004 displayTitle: SHOW TABLES
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 The `SHOW TABLES` statement returns all the tables for an optionally specified database.
0025 Additionally, the output of this statement may be filtered by an optional matching
0026 pattern. If no database is specified then the tables are returned from the
0027 current database.
0028
0029 ### Syntax
0030
0031 ```sql
0032 SHOW TABLES [ { FROM | IN } database_name ] [ LIKE regex_pattern ]
0033 ```
0034
0035 ### Parameters
0036
0037 * **{ FROM `|` IN } database_name**
0038
0039 Specifies the database name from which tables are listed.
0040
0041 * **regex_pattern**
0042
0043 Specifies the regular expression pattern that is used to filter out unwanted tables.
0044
0045 * Except for `*` and `|` character, the pattern works like a regular expression.
0046 * `*` alone matches 0 or more characters and `|` is used to separate multiple different regular expressions,
0047 any of which can match.
0048 * The leading and trailing blanks are trimmed in the input pattern before processing. The pattern match is case-insensitive.
0049
0050 ### Examples
0051
0052 ```sql
0053 -- List all tables in default database
0054 SHOW TABLES;
0055 +--------+---------+-----------+
0056 |database|tableName|isTemporary|
0057 +--------+---------+-----------+
0058 | default| sam| false|
0059 | default| sam1| false|
0060 | default| suj| false|
0061 +--------+---------+-----------+
0062
0063 -- List all tables from userdb database
0064 SHOW TABLES FROM userdb;
0065 +--------+---------+-----------+
0066 |database|tableName|isTemporary|
0067 +--------+---------+-----------+
0068 | userdb| user1| false|
0069 | userdb| user2| false|
0070 +--------+---------+-----------+
0071
0072 -- List all tables in userdb database
0073 SHOW TABLES IN userdb;
0074 +--------+---------+-----------+
0075 |database|tableName|isTemporary|
0076 +--------+---------+-----------+
0077 | userdb| user1| false|
0078 | userdb| user2| false|
0079 +--------+---------+-----------+
0080
0081 -- List all tables from default database matching the pattern `sam*`
0082 SHOW TABLES FROM default LIKE 'sam*';
0083 +--------+---------+-----------+
0084 |database|tableName|isTemporary|
0085 +--------+---------+-----------+
0086 | default| sam| false|
0087 | default| sam1| false|
0088 +--------+---------+-----------+
0089
0090 -- List all tables matching the pattern `sam*|suj`
0091 SHOW TABLES LIKE 'sam*|suj';
0092 +--------+---------+-----------+
0093 |database|tableName|isTemporary|
0094 +--------+---------+-----------+
0095 | default| sam| false|
0096 | default| sam1| false|
0097 | default| suj| false|
0098 +--------+---------+-----------+
0099 ```
0100
0101 ### Related Statements
0102
0103 * [CREATE TABLE](sql-ref-syntax-ddl-create-table.html)
0104 * [DROP TABLE](sql-ref-syntax-ddl-drop-table.html)
0105 * [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html)
0106 * [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html)