Query external data

更新时间:
复制 MD 格式

Use External Catalog to query data stored in external sources—no external tables required.

Prerequisites

Before you begin, ensure that you have:

  • A StarRocks instance. See Instance connection.

  • Different types of External Catalogs created in your cluster

Query external data

Step 1: Connect to the StarRocks instance

Connect to your StarRocks instance.

Step 2: Locate your External Catalog

  1. List all catalogs in the cluster:

    SHOW CATALOGS;
  2. List the databases in your target catalog:

    SHOW DATABASES FROM <catalog_name>;

Step 3: Query external data

Choose either approach based on your use case.

Single-catalog queries

Switch to the target catalog and database, then run your query with a short table name:

USE <catalog_name>.<db_name>;
SELECT * FROM <table_name>;

Cross-catalog queries

Use a fully-qualified three-part name to query tables across multiple catalogs in a single statement—no USE needed:

SELECT * FROM <catalog_name>.<db_name>.<table_name>;

Example

The following example queries hive_db.hive_table through a Hive Catalog named hive1.

Option 1: Switch context, then query

USE hive1.hive_db;
SELECT * FROM hive_table LIMIT 1;

Option 2: Fully-qualified name

SELECT * FROM hive1.hive_db.hive_table LIMIT 1;

What's next

  • To create more External Catalogs for other data sources, see the External Catalog creation documentation for your data source type.