SET RESOURCE GROUP
g
q
r
h
SET RESOURCE GROUP
is used to set the resource group for the current session.
Synopsis
SetResourceGroupStmt:
- SetResourceGroupStmt
- ResourceGroupName
SetResourceGroupStmt ::=
"SET" "RESOURCE" "GROUP" ResourceGroupName
ResourceGroupName ::=
Identifier
| "DEFAULT"
Examples
Create a user user1
, create two resource groups rg1
and rg2
, and bind the user user1
to the resource group rg1
.
CREATE USER 'user1';
CREATE RESOURCE GROUP 'rg1' RU_PER_SEC = 1000;
ALTER USER 'user1' RESOURCE GROUP `rg1`;
Use user1
to log in and view the resource group bound to the current user.
SELECT CURRENT_RESOURCE_GROUP();
+--------------------------+
| CURRENT_RESOURCE_GROUP() |
+--------------------------+
| rg1 |
+--------------------------+
1 row in set (0.00 sec)
Execute SET RESOURCE GROUP
to set the resource group for the current session to rg2
.
SET RESOURCE GROUP `rg2`;
SELECT CURRENT_RESOURCE_GROUP();
+--------------------------+
| CURRENT_RESOURCE_GROUP() |
+--------------------------+
| rg2 |
+--------------------------+
1 row in set (0.00 sec)
Execute SET RESOURCE GROUP
to specify the current session to use the default resource group.
SET RESOURCE GROUP `default`;
SELECT CURRENT_RESOURCE_GROUP();
+--------------------------+
| CURRENT_RESOURCE_GROUP() |
+--------------------------+
| default |
+--------------------------+
1 row in set (0.00 sec)
MySQL compatibility
MySQL also supports SET RESOURCE GROUP. But the accepted parameters are different from that of TiDB. They are not compatible.
See also
SET RESOURCE GROUPwas last updated 9/10/2024, 8:59:21 AM: *: update TiDB product names for non-cloud-console content (#18744) (#18874)