SHOW TABLES
現在または指定したデータベース内のテーブルを一覧表示します。
関連情報: system.tables
構文
SHOW [ FULL ] TABLES
[ {FROM | IN} <database_name> ]
[ HISTORY ]
[ LIKE '<pattern>' | WHERE <expr> ]
例
次の例は、現在のデータベース(default)内のすべてのテーブル名を一覧表示します。
SHOW TABLES;
┌───────────────────┐
│ Tables_in_default │
├───────────────────┤
│ books │
│ mytable │
│ ontime │
│ products │
└───────────────────┘
次の例は、追加情報を含めてすべてのテーブルを一覧表示します。
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 TABLE │ default │ default │ account_admin │ FUSE │ │ 2024-01-16 03:53:15.354132 │ 0 │ 0 │ 0 │ 0 │
│ mytable │ BASE TABLE │ default │ default │ account_admin │ FUSE │ │ 2024-01-16 03:53:27.968505 │ 0 │ 0 │ 0 │ 0 │
│ ontime │ BASE TABLE │ default │ default │ account_admin │ FUSE │ │ 2024-01-16 03:53:42.052399 │ 0 │ 0 │ 0 │ 0 │
│ products │ BASE TABLE │ default │ default │ account_admin │ FUSE │ │ 2024-01-16 03:54:00.883985 │ 0 │ 0 │ 0 │ 0 │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
次の例は、省略可能な HISTORY パラメーターが指定されている場合、結果に削除済みテーブルが含まれることを示しています。
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 │
└────────────────────────────────────────────────┘
次の例は、名前の末尾に文字列 "time" を含むテーブルを一覧表示します。
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';
次の例は、データサイズが 1,000 バイトを超えるテーブルを一覧表示します。
SHOW TABLES WHERE data_size > 1000 ;
┌───────────────────┐
│ Tables_in_default │
├───────────────────┤
│ ontime │
└───────────────────┘