Description
This statement is used to delete database objects from the recycle bin. It only supports deleting tenants, databases, tables, and indexes.
Syntax
PURGE {TENANT | DATABASE | TABLE | INDEX} object_name
object_name:
tenant_name
| database_name
| table_name
| index_name
Parameters
Parameters |
Description |
|---|---|
| tenant_name | Specifies the name of the tenant to be deleted. You can use either the original tenant name before deletion or the name in the recycle bin. Names in the recycle bin are unique, allowing you to specify a definite tenant; original tenant names may be duplicate, in which case the earliest tenant to enter the recycle bin is deleted. |
| database_name | Specifies the name of the database to be deleted in the recycle bin. You cannot directly specify the original name of the database. |
| table_name | Specifies the name of the table to be dropped. You can use either the original table name before deletion or the name in the recycle bin. If the database name is not specified, the table is dropped from the current database by default. When a database name is specified, it must be the current database. Original table names may be duplicated; in this case, the table that entered the recycle bin earliest is dropped. |
| index_name | Specifies the name of the index to be dropped. You can use either the original index name before deletion or the name in the recycle bin. If the database name is not specified, the index is dropped from the current database by default. When a database name is specified, only the specified database can be the current database. Original index names may be duplicated; in this case, the index that entered the recycle bin earliest is dropped. |
Examples
Delete the tenant
mysqlfrom the recycle bin.View objects in the recycle bin:
obclient> SHOW RECYCLEBIN;The query result is as follows:
+--------------------------------+---------------+--------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +--------------------------------+---------------+--------+----------------------------+ | __recycle_$_1_1599722585571328 | mysql | TENANT | 2020-09-10 15:36:54.712101 | +--------------------------------+---------------+--------+----------------------------+ 1 row in setDelete a tenant from the recycle bin:
obclient> PURGE TENANT mysql;View the recycle bin again:
obclient> SHOW RECYCLEBIN;The query result is as follows:
Empty setDelete the database
__recycle_$_1_1597384386029184from the recycle bin.Create and drop databases:
obclient> CREATE DATABASE db1; obclient> DROP DATABASE db1;View the recycle bin:
obclient> SHOW RECYCLEBIN;The query result is as follows:
+--------------------------------+---------------+----------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +--------------------------------+---------------+----------+----------------------------+ | __recycle_$_1_1597384386029184 | db1 | DATABASE | 2020-08-14 13:53:06.029367 | +--------------------------------+---------------+----------+----------------------------+ 1 row in setDelete a database from the recycle bin:
obclient> PURGE DATABASE __recycle_$_1_1597384386029184;View the recycle bin again:
obclient> SHOW RECYCLEBIN;The query result is as follows:
Empty setDelete tables from the recycle bin.
You can drop a table by using its original name or the name of the object in the recycle bin. The following example shows how to drop a table by using its original name:
Create and drop tables:
obclient> CREATE TABLE test(c1 INT); obclient> DROP TABLE test;View Recycle Bin:
obclient> SHOW RECYCLEBIN;The query result is as follows:
+-------------------------------------------+---------------+-------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +-------------------------------------------+---------------+-------+----------------------------+ | __recycle_$_1_1099511628776_1099511677778 | test | TABLE | 2017-10-20 17:40:22.304025 | +-------------------------------------------+---------------+-------+----------------------------+ 1 row in setDelete a table from the recycle bin by using its original name:
obclient> PURGE TABLE test;or delete it by using the object name from the recycle bin:
obclient> PURGE TABLE __recycle_$_1_1099511628776_1099511677778;View the recycle bin again:
obclient> SHOW RECYCLEBIN;The query result is as follows:
Empty setDelete an index from the recycle bin.
You can delete an index by using its original name or the name of the object in the recycle bin. The following example shows how to delete an index by using its original name:
Create tables and indexes, and drop tables:
obclient> CREATE TABLE t1(c1 INT); obclient> CREATE INDEX idx ON t1(c1); obclient> DROP TABLE t1;View Recycle Bin:
obclient> SHOW RECYCLEBIN;The query result is as follows:
+--------------------------------+----------------------------+-------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +--------------------------------+----------------------------+-------+----------------------------+ | __recycle_$_1_1597387726700872 | __idx_1101710651081557_idx | INDEX | 2020-08-14 14:48:46.699145 | | __recycle_$_1_1597387726712976 | t1 | TABLE | 2020-08-14 14:48:46.712643 | +--------------------------------+----------------------------+-------+----------------------------+ 2 rows in setDelete an index from the recycle bin by using its original name:
obclient> PURGE INDEX idx;or delete it by using the object name in the recycle bin:
obclient> PURGE INDEX __recycle_$_1_1597387726700872;View the recycle bin again:
obclient> SHOW RECYCLEBIN;The query result is as follows:
+--------------------------------+----------------------------+-------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +--------------------------------+----------------------------+-------+----------------------------+ | __recycle_$_1_1597387726712976 | t1 | TABLE | 2020-08-14 14:48:46.712643 | +--------------------------------+----------------------------+-------+----------------------------+ 1 rows in set