USE
USE specifies the database for the current session. After the database is specified, you can perform subsequent operations such as creating tables or running queries.
Syntax
USE [<catalog_name>.]<db_name>;
Parameters
|
Parameter |
Required |
Description |
|
|
No |
The catalog name.
This parameter is supported since version 3.2.7. |
|
|
Yes |
The database name. The database must exist. |
Examples
Example 1: Use the example_db database under the adb catalog as the session database.
USE adb.example_db;
Or
USE example_db;
Example 2: Use the example_db database under the paimon_catalog catalog as the session database.
USE paimon_catalog.example_db;
Example 3: Switch the session database from paimon_catalog.example_db1 to iceberg_catalog.example_db2.
USE iceberg_catalog.example_db2;
Usage notes
-
USEtakes effect only for the current session and does not affect other connections. -
The syntax for specifying
catalog_nameis supported since AnalyticDB for MySQL 3.2.7. -
Regardless of the active catalog, you can always query across catalogs using the three-part name
<catalog>.<database>.<table>.