USE DATABASE
Descriptionβ
Used to switch to the specified database or compute group.
Syntaxβ
USE { [<catalog_name>.]<database_name>[@<compute_group_name>] | @<compute_group_name> }
Required Parametersβ
Switch to the specified database.
1. <database_name>
The name of the database to switch to. If no catalog is specified, the current catalog is used by default.
Switch to the specified compute group only.
1. <compute_group_name>
The name of the compute group to switch to.
Optional Parametersβ
Switch to the specified database.
1. <catalog_name>
The name of the catalog to switch to.
2. <compute_group_name>
The name of the compute group to switch to.
Access Control Requirementsβ
Privilege | Object | Notes |
---|---|---|
SELECT_PRIV | Catalog, Database | SELECT_PRIV privilege is required on the catalog or database to switch to. |
USAGE_PRIV | Compute Group | USAGE_PRIV privilege is required on the compute group to switch to. |
Examplesβ
-
If the
demo
database exists, try to use it:use demo;
-
If the
demo
database exists under thehms_catalog
catalog, try to switch tohms_catalog
and use it:use hms_catalog.demo;
-
If the
demo
database exists in the current catalog and you want to use the compute group named 'cg1', try to access it:use demo@cg1;
-
If you only want to use the compute group named 'cg1', try to access it:
use @cg1;