OceanBase AI Database supports dropping a tenant by using the DROP TENANT statement.
After a tenant is dropped, the databases and tables in the tenant are also dropped. However, the resource pools used by the tenant are not dropped and can continue to be used by other tenants.
If the recycle bin feature is enabled for the
systenant, theDROP TENANTstatement moves the specified tenant to the recycle bin. For tenants in the recycle bin, thesystenant can later purge or restore them by using the tenant-level recycle bin feature. For more information about the recycle bin feature, see Overview of the recycle bin.If the recycle bin feature is disabled for the
systenant, theDROP TENANTstatement directly drops the tenant along with its databases and tables.
Procedure
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xx.xx -P2883 -uroot@sys#cluster -p**** -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> USE oceanbase;Query the
DBA_OB_TENANTSview for information about a tenant. Verify the tenant to be dropped based on the tenant ID, creation time, and resource information.To query information about the
mq_t1tenant, execute the following statement:obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, CREATE_TIME, PRIMARY_ZONE, LOCALITY, COMPATIBILITY_MODE, STATUS FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';The query result is as follows:
+-----------+-------------+-------------+----------------------------+--------------+---------------+--------------------+--------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | PRIMARY_ZONE | LOCALITY | COMPATIBILITY_MODE | STATUS | +-----------+-------------+-------------+----------------------------+--------------+---------------+--------------------+--------+ | 1036 | mq_t1 | USER | 2023-01-11 00:23:36.317242 | zone1;zone2 | FULL{1}@zone1 | MYSQL | NORMAL | +-----------+-------------+-------------+----------------------------+--------------+---------------+--------------------+--------+ 1 row in setFor detailed information about the
DBA_OB_TENANTSview, see DBA_OB_TENANTS.(Optional) OceanBase AI Database provides the tenant-level recycle bin feature to ensure the recoverability of data lost due to malicious operations or misoperations. The recycle bin feature is disabled by default. You can enable it for a tenant as needed. For more information about the recycle bin, see Overview of the recycle bin.
You can execute the
SHOW RECYCLEBINstatement in thesystenant to view the objects in the recycle bin of thesystenant. Here is an example:obclient(root@sys)[oceanbase]> SHOW RECYCLEBIN;The query result is as follows:
+--------------------------------+-----------------+----------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +--------------------------------+-----------------+----------+----------------------------+ | __recycle_$_1_1600136460199936 | obdemo_table | TABLE | 2020-09-15 10:21:00.207886 | | __recycle_$_1_1600136479664128 | obdemo_database | DATABASE | 2020-09-15 10:21:19.664534 | | __recycle_$_1_1600135793000960 | omysql | TENANT | 2020-09-15 10:23:25.773877 | +--------------------------------+-----------------+----------+----------------------------+ 3 rows in setwhere:
OBJECT_NAME: the name of an object in the recycle bin.ORIGINAL_NAME: the original name of the object.TYPE: the type of the object in the recycle bin. Valid values: INDEX, TABLE, DATABASE, and TENANT. In this example,omysqlis a tenant object in the recycle bin.CREATETIME: the time when the object was moved to the recycle bin.
Execute the
DROP TENANTstatement to drop a tenant.obclient(root@sys)[oceanbase]> DROP TENANT mq_t1;For more information about the
DROP TENANTstatement, see DROP TENANT.Query the
DBA_OB_TENANTSview to verify whether the tenant is successfully dropped.obclient(root@sys)[oceanbase]> SELECT * FROM DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1'; Empty set(Optional) If the recycle bin feature is enabled in step 4, you can execute the
SHOW RECYCLEBINstatement to view the objects in the recycle bin.obclient(root@sys)[oceanbase]> SHOW RECYCLEBIN;The query result is as follows:
+-------------------------------------+---------------+--------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +-------------------------------------+---------------+--------+----------------------------+ | __recycle_$_100017_1673367572701376 | mq_t1 | TENANT | 2023-01-11 00:23:36.317242 | +-------------------------------------+---------------+--------+----------------------------+ 1 row in setFor more information about recycle bin parameters, see recyclebin.
References
For information about how to restore a dropped tenant, see: