Purpose
The CREATE TENANT ... FROM ... statement is used to quickly clone a new tenant from an existing one.
Limitations and considerations
- This statement must be executed in the
systenant. - Tenant cloning can only be performed on a standby tenant; it cannot be performed on a primary tenant.
- Only user tenants can be cloned. The
sysandmetatenants cannot be cloned. - The source tenant and its corresponding meta tenant must be in the
NORMALstate and cannot be in the recyclebin or dropping state. - The source tenant and the target tenant for cloning must be in the same cluster.
- Before cloning, you must pre-create the unit config to be used by the target tenant. The resource pool name for the target tenant must be unique and is created by the system based on the source tenant layout.
- A cloned tenant is a standby tenant by default. To provide primary database services externally, you must execute the
ALTER SYSTEM SWITCHOVER TO PRIMARYstatement to switch it to a primary tenant. - Archiving must be enabled, and the round state must be
DOING.
Privilege requirements
Only the root user of the sys tenant (root@sys) can execute this statement.
Syntax
CREATE TENANT clone_tenant_name
FROM source_tenant_name
WITH clone_option_list;
clone_option_list:
clone_option [, clone_option ...]
clone_option:
RESOURCE_POOL [=] pool_name
| UNIT [=] unit_config_name
Parameters
Parameter |
Description |
|---|---|
| clone_tenant_name | Specifies the name of the target tenant for the cloned database. |
| source_tenant_name | Specifies the name of the source tenant. |
| RESOURCE_POOL [=] pool_name | Specifies the new name of the resource pool for the target tenant. |
| UNIT [=] unit_config_name | Specifies the unit config name used by the target tenant. |
Examples
Clone a new tenant
clone_tenantbased on the current state of the source tenantsource_tenant, and specify the resource pool and unit config.obclient> CREATE TENANT clone_tenant FROM source_tenant WITH RESOURCE_POOL = 'clone_pool', UNIT = 'unit_config';
