Skip to main content

SHOW TABLES

Introduced or updated: v1.2.415

Lists the tables in the current or a specified database.

note

Starting from version 1.2.415, the SHOW TABLES command no longer includes views in its results. To display views, use SHOW VIEWS instead.

See also: system.tables

Syntax

SHOW [ FULL ] TABLES 
[ {FROM | IN} <database_name> ]
[ HISTORY ]
[ LIKE '<pattern>' | WHERE <expr> ]
ParameterDescription
FULLLists the results with additional information. See Examples for more details.
FROM / INSpecifies a database. If omitted, the command returns the results from the current database.
HISTORYDisplays the timestamps of table deletions within the retention period (24 hours by default). If a table has not been deleted yet, the value for drop_time is NULL.
LIKEFilters the results by their names using case-sensitive pattern matching.
WHEREFilters the results using an expression in the WHERE clause.

Examples

The following example lists the names of all tables in the current database (default):

SHOW TABLES;

┌───────────────────┐
│ Tables_in_default │
├───────────────────┤
│ books │
│ mytable │
│ ontime │
│ products │
└───────────────────┘

The following example lists all the tables with additional information:

SHOW FULL TABLES;

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
tables │ table_type │ database │ catalog │ owner │ engine │ cluster_by │ create_time │ num_rows │ data_size │ data_compressed_size │ index_size │
├──────────┼────────────┼──────────┼─────────┼──────────────────┼────────┼────────────┼────────────────────────────┼──────────────────┼──────────────────┼──────────────────────┼──────────────────┤
│ books │ BASE TABLEdefaultdefault │ account_admin │ FUSE │ │ 2024-01-16 03:53:15.3541320000
│ mytable │ BASE TABLEdefaultdefault │ account_admin │ FUSE │ │ 2024-01-16 03:53:27.9685050000
│ ontime │ BASE TABLEdefaultdefault │ account_admin │ FUSE │ │ 2024-01-16 03:53:42.0523990000
│ products │ BASE TABLEdefaultdefault │ account_admin │ FUSE │ │ 2024-01-16 03:54:00.8839850000
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

The following example demonstrates that the results will include dropped tables when the optional parameter HISTORY is present:

DROP TABLE products;

SHOW TABLES;

┌───────────────────┐
│ Tables_in_default │
├───────────────────┤
│ books │
│ mytable │
│ ontime │
└───────────────────┘

SHOW TABLES HISTORY;

┌────────────────────────────────────────────────┐
│ Tables_in_default │ drop_time │
├───────────────────┼────────────────────────────┤
│ books │ NULL
│ mytable │ NULL
│ ontime │ NULL
│ products │ 2024-01-16 03:55:47.900362
└────────────────────────────────────────────────┘

The following example lists the tables containing the string "time" at the end of their name:

SHOW TABLES LIKE '%time';

┌───────────────────┐
│ Tables_in_default │
├───────────────────┤
│ ontime │
└───────────────────┘

-- CASE-SENSITIVE pattern matching.
-- No results will be returned if you code the previous statement like this:
SHOW TABLES LIKE '%TIME';

The following example lists tables where the data size is greater than 1,000 bytes:

SHOW TABLES WHERE data_size > 1000 ;

┌───────────────────┐
│ Tables_in_default │
├───────────────────┤
│ ontime │
└───────────────────┘
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today