跳到主要内容
版本: 最新版本-3.5

SHOW TABLES

SHOW TABLES 显示 StarRocks 数据库或外部数据源(例如 Hive、Iceberg、Hudi 或 Delta Lake)中的数据库中的所有表。

注意

要查看外部数据源中的表,您必须对与该数据源对应的外部 Catalog 具有 USAGE 权限。

语法

SHOW TABLES [FROM <catalog_name>.<db_name>]

参数

参数必需描述
catalog_name内部 Catalog 或外部 Catalog 的名称。
  • 如果您未指定此参数或将其设置为 default_catalog,则返回 StarRocks 数据库中的表。
  • 如果您将此参数设置为外部 Catalog 的名称,则返回外部数据源的数据库中的表。
您可以运行 SHOW CATALOGS 来查看内部和外部 Catalog。
db_name数据库名称。如果未指定,则默认使用当前数据库。

示例

示例 1:连接到 StarRocks 集群后,查看 default_catalogexample_db 数据库中的表。以下两个语句等效。

show tables from example_db;
+----------------------------+
| Tables_in_example_db |
+----------------------------+
| depts |
| depts_par |
| emps |
| emps2 |
+----------------------------+

show tables from default_catalog.example_db;
+----------------------------+
| Tables_in_example_db |
+----------------------------+
| depts |
| depts_par |
| emps |
| emps2 |
+----------------------------+

示例 2:连接到数据库后,查看当前数据库 example_db 中的表。

show tables;
+----------------------------+
| Tables_in_example_db |
+----------------------------+
| depts |
| depts_par |
| emps |
| emps2 |
+----------------------------+

示例 2:查看外部 Catalog hudi_cataloghudi_db 数据库中的表。

show tables from hudi_catalog.hudi_db;
+----------------------------+
| Tables_in_hudi_db |
+----------------------------+
| hudi_sync_mor |
| hudi_table1 |
+----------------------------+

或者,您可以运行 SET CATALOG 切换到外部 Catalog hudi_catalog,然后运行 SHOW TABLES FROM hudi_db;

参考