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
demodatabase exists, try to use it:use demo; -
If the
demodatabase exists under thehms_catalogcatalog, try to switch tohms_catalogand use it:use hms_catalog.demo; -
If the
demodatabase 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;