In addition to the recycle bin for databases, tables, and indexes, OceanBase Database also provides a recycle bin for tenants.
The system tenant will not be dropped, and the recycle bin for tenant is managed by the system tenant by using commands.
Objects in the recycle bin for tenants are available only to the system tenant.
Notes:
The
DROP TENANTcommand converts a tenant name to the uniform format in the recycle bin. The space occupied by the tenant is not released, but a new connection cannot be established to the tenant.The
FLASHBACKcommand uses the original tenant name or the tenant name in the recycle bin. The tenant name in the recycle bin is globally unique and therefore can identify the tenant to be restored. If multiple tenants have the same original name, the last tenant moved to the recycle bin is to be restored.The
PURGE TENANTcommand can also use the original tenant name or the tenant name in the recycle bin. UnlikeFLASHBACK, when multiple tenants have the same original name, thePURGE TENANTcommand deletes the first tenant moved to the recycle bin.
View the recycle bin
You can run the SHOW RECYCLEBIN command under the system tenant to view its recycle bin.
Example:
obclient> SHOW RECYCLEBIN;
+--------------------------------+----------------+----------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------+----------------+----------+----------------------------+
| __recycle_$_1_1600136460199936 | wendo_table | TABLE | 2020-09-15 10:21:00.207886 |
| __recycle_$_1_1600136479664128 | wendo_database | DATABASE | 2020-09-15 10:21:19.664534 |
| __recycle_$_1_1600135793000960 | mysql | TENANT | 2020-09-15 10:23:25.773877 |
+--------------------------------+----------------+----------+----------------------------+
3 rows in set (0.21 sec)
OBJECT_NAME indicates the name in the recycle bin, and ORIGINAL_NAME indicates the original name.
In this example, mysql is a tenant object in the recycle bin.
Enable and disable the recycle bin
You can run the SET command under the system tenant to enable or disable its recycle bin.
Examples:
Enable the recycle bin
obclient> SET GLOBAL recyclebin=true; Query OK, 0 rows affected (0.01 sec)
Disable the recycle bin
obclient> SET GLOBAL recyclebin=false; Query OK, 0 rows affected (0.01 sec)
Restore objects from the recycle bin
By default, when the recycle bin is enabled for the system tenant, the DROP TENANT command moves the specified tenant to the recycle bin. You can run the FLASHBACK command to restore the tenant from the recycle bin.
Examples:
Restore
tenant_namefrom the recycle bin of the system tenantobclient> FLASHBACK TENANT <tenant_name> TO BEFORE DROP;
Restore
tenant_namefrom the recycle bin of the system tenant and rename itnew_tenant_nameobclient> FLASHBACK TENANT <tenant_name> TO BEFORE DROP RENAME TO <new_tenant_name>;
Purge the recycle bin
You can run the PURGE command under the system tenant to permanently delete the objects in the recycle bin.
Purge
tenant_namefrom the recycle binobclient> PURGE TENANT tenant_name;
Purge all objects from the recycle bin
obclient> PURGE RECYCLEBIN;Note
Constraints for the primary/standby cluster configuration
You cannot run the
DROP TENANT,DROP TENANT FORCE,DROP TENANT PURGE,FLASHBACK TENANT, orPURGE TENANTcommand for a standby cluster. All these operations must be synchronized from the primary cluster.You can run the
PURGE RECYCLEBINcommand for a standby cluster, but it does not delete tenants from the recycle bin.