Purpose
You can use this statement to create a tenant.
Note
To execute this statement, you must log on to the sys tenant as the root user.
Syntax
CREATE TENANT [IF NOT EXISTS] tenant_name
[tenant_characteristic_list] [opt_set_sys_var];
tenant_characteristic_list:
tenant_characteristic [, tenant_characteristic...]
tenant_characteristic:
COMMENT 'string'
| {CHARACTER SET | CHARSET} [=] charsetname
| COLLATE [=] collationname
| ZONE_LIST [=] (zone [, zone...])
| PRIMARY_ZONE [=] zone
| DEFAULT TABLEGROUP [=] {NULL | tablegroup}
| RESOURCE_POOL_LIST [=](poolname [, poolname...])
| LOCALITY [=] 'locality description'
opt_set_sys_var:
{SET | SET VARIABLES | VARIABLES} system_var_name = expr [,system_var_name = expr] ...
Parameters
| Parameter | Description |
|---|---|
| tenant_name | The name of the tenant. The name cannot exceed 128 characters in length. It must contain only uppercase and lowercase letters, digits, and underscores (_). The name must start with a letter or an underscore (_) and must not contain reserved keywords of OceanBase Database. |
| IF NOT EXISTS | If the tenant name already exists and IF NOT EXISTS is not specified, an error is returned. |
| RESOURCE_POOL_LIST | The list of resource pools. This parameter is required when you create a tenant. |
| DEFAULT TABLEGROUP | The default table group of the tenant. When you set it to NULL, the system disables the default table group. If this parameter is not specified, the default value is NULL. |
| COMMENT | The comment. |
| CHARACTER SET | CHARSET | The character set. |
| COLLATE | The collation. |
| PRIMARY_ZONE | The name of the primary zone of the tenant. |
| LOCALITY | The distribution of replicas across zones. For example, F@z1,F@z2,F@z3 indicates that z1, z2, and z3 are full-featured replicas. |
| system_var_name | The system variables of the tenant. ob_compatibility_mode specifies the compatibility mode of the tenant. Valid values: MySQL and Oracle. You can specify the compatibility mode only when you create the tenant. If you do not specify this parameter, the compatibility mode is MySQL by default. |
Examples
Create a tenant.
obclient> CREATE TENANT IF NOT EXISTS tenant1 CHARSET='utf8mb4',PRIMARY_ZONE='zone1', RESOURCE_POOL_LIST=('pool1') set ob_tcp_invited_nodes='%';Create a tenant in Oracle mode.
obclient> CREATE TENANT IF NOT EXISTS tenant1 ZONE_LIST=('zone1'), PRIMARY_ZONE='zone1', RESOURCE_POOL_LIST=('pool1') SET ob_compatibility_mode='oracle', set ob_tcp_invited_nodes='%';