Frequent deletion and rebuilding of database objects generate a large amount of data in the recycle bin. You can purge the recycle bin to clear the data.
The recycle bin can be manually or automatically purged. In the sys tenant, you can purge INDEX, TABLE, DATABASE, and TENANT objects from the recycle bin. In a MySQL user tenant, you can purge INDEX, TABLE, and DATABASE objects from the recycle bin. In an Oracle user tenant, you can purge INDEX and TABLE objects from the recycle bin.
Manually purge the recycle bin
You can execute the PURGE statement to purge the recycle bin.
Considerations
The
PURGEstatement deletes an object along with its dependent objects in the recycle bin. For example, when you purge a database from the recycle bin in MySQL mode, tables and indexes in the database are also purged.When an upper-layer object of a current object is purged, the objects dependent on the current object in the recycle bin are also purged.
Before you execute the
PURGEstatement, we recommend that you check the objects to be deleted in the recycle bin. ThePURGEstatement deletes the information about an object in the recycle bin of OceanBase Database. The actual data is also deleted.
Procedure
Log on to the database as an administrator of the
systenant or a user tenant.Note
- The administrator user of a MySQL user tenant is
rootand that of an Oracle user tenant isSYS. - If you want to purge tenants from the recycle bin, log on to the database as an administrator of the
systenant.
Example (the command can vary in practice):
obclient -h10.xx.xx.xx -P2883 -uroot@sys -p***** -AFor more information, see Database connection overview.
- The administrator user of a MySQL user tenant is
Execute the
SHOW RECYCLEBINstatement to query for the names of objects in the recycle bin.obclient [(none)]> SHOW RECYCLEBIN; +-------------------------------------+-------------------+----------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +-------------------------------------+-------------------+----------+----------------------------+ | RECYCLE_$_100017_1672050541224936 | oracle001 | TENANT | 2023-01-16 11:01:40.258000 | | __recycle_$_100017_1673426335319344 | __idx_500788_idx1 | INDEX | 2023-01-11 16:38:55.318878 | | __recycle_$_100017_1673426335331800 | t1 | TABLE | 2023-01-11 16:38:55.331481 | | __recycle_$_100017_1673854707660504 | infotest | DATABASE | 2023-01-16 15:38:27.660436 | +-------------------------------------+-------------------+----------+----------------------------+ 4 rows in setPurge the recycle bin in an appropriate way based on your business needs.
Purge a tenant from the recycle bin
If you purge a tenant from the recycle bin, all objects in the tenant are purged. You can purge tenants from the recycle bin only in the
systenant.Sample statement:
obclient [(none)]> PURGE TENANT tenant_name;tenant_namespecifies the name of the tenant in the recycle bin or the original name of the tenant. If multiple tenants have the same original name, the first tenant moved to the recycle bin is purged.Example:
obclient [(none)]> PURGE TENANT oracle001; obclient [(none)]> PURGE TENANT RECYCLE_$_100017_1672050541224936;Physically purge a database from the recycle bin
You can purge databases from the recycle bin only in the
systenant or a MySQL user tenant.obclient> PURGE DATABASE object_name;object_namespecifies the name of the database in the recycle bin. You cannot set this parameter to the original name of the database.Example:
obclient [(none)]> PURGE DATABASE __recycle_$_100017_1673854707660504;Physically purge a table from the recycle bin
obclient> PURGE TABLE object_name;object_namespecifies the name of the table in the recycle bin or the original name of the table. If multiple tables have the same original name, the first table moved to the recycle bin is purged.Example:
obclient [(none)]> PURGE TABLE __recycle_$_100017_1673426335331800;Physically purge an index from the recycle bin
obclient> PURGE INDEX object_name;object_namespecifies the name of the index in the recycle bin. You cannot set this parameter to the original name of the index.Example:
obclient [(none)]> PURGE INDEX __recycle_$_100017_1673426335319344;Purge all objects from the recycle bin
obclient [(none)]> PURGE RECYCLEBIN;
Execute the
SHOW RECYCLEBINstatement to check whether all the objects are purged from the recycle bin.obclient [(none)]> SHOW RECYCLEBIN;
Automatically purge the recycle bin
OceanBase Database allows you to set the recyclebin_object_expire_time parameter for a cluster to automatically purge expired schema objects from the recycle bin. The default value of this parameter is 0s.
When the value is
0s, the schema objects in the recycle bin will not be automatically purged.When the value is not
0s, the schema objects that have been stored in the recycle bin for the specified period of time are automatically purged.
For more information about the recyclebin_object_expire_time parameter, see recyclebin_object_expire_time.
Log on to the
systenant as therootuser.Example (the command can vary in practice):
obclient -h10.xx.xx.xx -P2883 -uroot@sys -p***** -AFor more information, see Database connection overview.
Execute the following statement to enable automatic purge of the recycle bin and specify the expiration period for objects in the recycle bin.
For example, you can execute the following statement to automatically purge schema objects that have been stored in the recycle bin for seven days:
obclient [(none)]> ALTER SYSTEM SET recyclebin_object_expire_time = '7d';(Optional) Execute the following statement to check whether the objects that meet the specified conditions are purged from the recycle bin:
obclient [(none)]> SHOW RECYCLEBIN;
More information
For more information about the recycle bin, see the following topics: