USE COMPUTE GROUP
Descriptionβ
In the storage-and-compute-separated version, specify the compute cluster to use.
Syntaxβ
USE { [ <catalog_name>. ]<database_name>[ @<compute_group_name> ] | @<compute_group_name> }
Required Parametersβ
<compute_group_name>
οΌ The name of the compute cluster.
Return Valueβ
If the compute cluster switch is successful, it returns "Database changed"; if the switch fails, it returns the corresponding error message.
Examplesβ
-
Specify the compute cluster
compute_cluster
to use:use @compute_cluster;
Database changed -
Specify both the database
mysql
and the compute clustercompute_cluster
to use:use mysql@compute_cluster
Database changed
Permission Controlβ
The prerequisite for successfully executing this SQL command is to have the USAGE_PRIV permission for the compute group, refer to the permission documentation.
Privilege | Object | Notes |
---|---|---|
USAGE_PRIV | Compute group | Permission to use the compute cluster |
If a user does not have the compute group permission and tries to specify a compute group, an error will be reported. For example, test
is a regular user without compute group permission:
mysql -utest -h175.40.1.1 -P9030
use @compute_cluster;
ERROR 5042 (42000): errCode = 2, detailMessage = USAGE denied to user test'@'127.0.0.1' for compute group 'compute_cluster'
Notesβ
-
If the database name or compute group name is a reserved keyword, it needs to be enclosed in backticks, for example:
use @`create`
-
If the compute group does not exist, an error message will be returned:
mysql> use @compute_group_not_exist;
ERROR 5098 (42000): errCode = 2, detailMessage = Compute Group compute_group_not_exist not exist