> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Query external data

> How to query data from external sources in the database using external catalogs.

This topic guides you through querying data from external data sources by using external catalogs.

## Prerequisites

External catalogs are created based on external data sources. For information about supported types of external catalogs, see [Catalog](/documents/4.2/data_source/catalog/catalog_overview.md#catalog).

## Procedure

1. Connect your cluster.
   * If you use the MySQL client to connect the cluster, you go to `default_catalog` by default after connecting.
   * If you use JDBC to connect the cluster, you can go directly to the destination database in the default catalog by specifying `default_catalog.db_name` when connecting.

2. (Optional) Execute the following statement to view all the catalogs and find the external catalog you have created. See [SHOW CATALOGS](/documents/4.2/sql-reference/sql-statements/Catalog/SHOW_CATALOGS.md) to check the output of this statement.

   ```SQL theme={null}
   SHOW CATALOGS;
   ```

3. (Optional) Execute the following statement to view all the databases in the external catalog. See [SHOW DATABASES](/documents/4.2/sql-reference/sql-statements/Database/SHOW_DATABASES.md) to check the output of this statement.

   ```SQL theme={null}
   SHOW DATABASES FROM catalog_name;
   ```

4. (Optional) Execute the following statement to go to the destination database in the external catalog.

   ```SQL theme={null}
   USE catalog_name.db_name;
   ```

5. Query external data. For more usages of the SELECT statement, see [SELECT](/documents/4.2/sql-reference/sql-statements/table_bucket_part_index/SELECT/SELECT.md).

   ```SQL theme={null}
   SELECT * FROM table_name;
   ```

   If you do not specify the external catalog and database in the preceding steps, you can directly specify them in a select query.

   ```SQL theme={null}
   SELECT * FROM catalog_name.db_name.table_name;
   ```

## Examples

If you already created a Hive catalog named `hive1` and want to use `hive1` to query data from `hive_db.hive_table` of an Apache Hive™ cluster, you can perform one of the following operations:

```SQL theme={null}
USE hive1.hive_db;
SELECT * FROM hive_table limit 1;
```

Or

```SQL theme={null}
SELECT * FROM hive1.hive_db.hive_table limit 1;
```

## References

To query data from your cluster, see [Default catalog](/documents/4.2/data_source/catalog/default_catalog.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.