Purpose
You can use this statement to modify the attributes of a user tenant, including the locality, primary zone, resource pool list, and system variable values.
You can use the ALTER TENANT ... RENAME statement to rename a user tenant.
You can use the ALTER TENANT ... LOCK/UNLOCK statement to lock or unlock a user tenant. After you lock a tenant, you cannot create a connection on the tenant. However, existing connections are not affected.
Required privileges
You can modify the attributes of a tenant only as the root user of the sys tenant (namely root@sys).
Syntax
ALTER TENANT
ALTER TENANT tenant_name
[SET] [tenant_option_list] [set_sys_var];
tenant_option_list:
tenant_option [, tenant_option ...]
tenant_option:
LOCALITY [=] 'locality_description'
| PRIMARY_ZONE [=] zone
| RESOURCE_POOL_LIST [=](pool_name [, pool_name...])
| ENABLE_ARBITRATION_SERVICE [=] {True | False}
| [DEFAULT] TABLEGROUP [=] {NULL | tablegroup_name}
| ENABLE_EXTENDED_ROWID [=] {true | false}
| COMMENT [=]'string'
set_sys_var:
VARIABLES var_name {TO | =} var_value [,var_name {TO | =} var_value...]
ALTER TENANT … RENAME
ALTER TENANT tenant_name RENAME GLOBAL_NAME TO new_tenant_name;
ALTER TENANT … LOCK / UNLOCK
ALTER TENANT tenant_name LOCK | UNLOCK;
Parameters
| Parameter | Description |
|---|---|
| tenant_name | The name of the tenant to be modified. |
| LOCALITY | Modifies the locality of the tenant. Locality describes the distribution of replicas across zones. For example, F@z1,F@z2,F@z3 indicates that z1, z2, and z3 are full-featured replicas. If you want to add a zone, you must make sure that this zone is included in the ZONE_LIST setting of the resource pool of the tenant. |
| PRIMARY_ZONE | Modifies the primary zone of the tenant. Valid values:
If you do not specify this parameter when you create a tenant, the default value RANDOM is used. |
| RESOURCE_POOL_LIST | Modifies the resource pool list of the tenant. If the tenant has multiple resource pools, they must have the same UNIT_NUM value, which indicates the number of resource units.
Notice
|
| ENABLE_ARBITRATION_SERVICE | Modifies the enabling status of the arbitration service, if it is deployed for the tenant. |
| [DEFAULT] TABLEGROUP | Modifies the default table group of the tenant. The value NULL specifies to disable the default table group. |
| ENABLE_EXTENDED_ROWID | Specifies whether to enable the Extended ROWID mode for all tables in the tenant. After you enable this mode, it cannot be disabled. However, you can use the tenant-level parameter default_enable_extended_rowid to specify whether to enable the Extended ROWID mode for tables created later. For more information about the default_enable_extended_rowid parameter, see default_enable_extended_rowid. |
| system_var_name | Modifies the system variable values of the tenant. |
| RENAME GLOBAL_NAME TO | Renames the tenant. |
| COMMENT | Modifies the comment. |
Examples
Change the primary zone of
tenant1tozone2.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone='zone2';You need to modify the resource pool list generally when you increase or decrease the number of replicas for a tenant. When you modify the resource pool list for a tenant, you can add or remove only one resource pool at a time. You cannot directly replace one resource pool with another.
obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool2');If you execute the preceding statement to replace the
pool1resource pool with thepool2resource pool, the following error message will be returned:ERROR 1210 (HY000): Incorrect arguments to resource pool listIf you want to increase the available resources of a tenant, you can upgrade the unit config of the resource units of the tenant.
obclient [oceanbase]> ALTER RESOURCE UNIT unit1 MAX_CPU 15, MEMORY_SIZE '20G', MAX_IOPS 1280, MIN_CPU=10, MIN_IOPS=1024;Modify the locality of
tenant1to increase the number of replicas.Findicates a full-featured replica, andB_4is the name of the zone to be created.Create a resource unit named
unit2.obclient [oceanbase]> CREATE RESOURCE UNIT unit2, MAX_CPU=5, MIN_CPU=2.5, MEMORY_SIZE= '32G', MAX_IOPS=10000, MIN_IOPS=5000, LOG_DISK_SIZE=5301023539200;Create a resource pool named
pool2.obclient [oceanbase]> CREATE RESOURCE POOL pool2 unit='unit2',unit_num=1,zone_list=('B_4');Add the resource pool
pool2to the resource pool list of the tenant.obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool1','pool2');Modify the locality of the tenant.
obclient [oceanbase]> ALTER TENANT tenant1 locality="F@B_1,F@B_2,F@B_3,F@B_4";
If the arbitration service is deployed, enable the arbitration service for
tenant1.obclient [oceanbase]> ALTER TENANT tenant1 ENABLE_ARBITRATION_SERVICE=true;Rename the
tenant1tenant astenant101.obclient [oceanbase]> ALTER TENANT tenant1 RENAME GLOBAL_NAME TO tenant101;Lock the
tenant1tenant.obclient [oceanbase]> ALTER TENANT tenant1 LOCK;