OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.0
    iconOceanBase Database
    SQL - V 4.2.0
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Purge the recycle bin

    Last Updated:2023-10-31 11:17:10  Updated
    share
    What is on this page
    Manually purge the recycle bin
    Considerations
    Procedure
    Automatically purge the recycle bin
    References

    folded

    share

    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 PURGE statement 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 PURGE statement, we recommend that you check the objects to be deleted in the recycle bin. The PURGE statement deletes the information about an object in the recycle bin of OceanBase Database. The actual data is also deleted.

    Procedure

    1. Log on to the database as an administrator of the sys tenant or a user tenant.

      Note

      • The administrator user of a MySQL user tenant is root and that of an Oracle user tenant is SYS.
      • If you want to purge tenants from the recycle bin, log on to the database as an administrator of the sys tenant.

      Note that you must specify the corresponding fields in the following sample code based on your actual database configurations.

      obclient -h10.xx.xx.xx -P2883 -uroot@sys -p***** -A
      

      For more information about how to connect to a database, see Overview (MySQL mode) or Overview (Oracle mode).

    2. Execute the SHOW RECYCLEBIN statement 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 set
      
    3. Purge 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 sys tenant.

        The syntax is as follows:

        obclient [(none)]> PURGE TENANT tenant_name;
        

        Here, tenant_name specifies 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.

        For 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 sys tenant or a MySQL user tenant.

        obclient> PURGE DATABASE object_name;
        

        Here, object_name specifies the name of the database in the recycle bin. You cannot set this parameter to the original name of the database.

        For example:

        obclient [(none)]> PURGE DATABASE __recycle_$_100017_1673854707660504;
        
      • Physically purge a table from the recycle bin

        obclient> PURGE TABLE object_name;
        

        Here, object_name specifies 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.

        For example:

        obclient [(none)]> PURGE TABLE __recycle_$_100017_1673426335331800;
        
      • Physically purge an index from the recycle bin

        obclient> PURGE INDEX object_name;
        

        Here, object_name specifies the name of the database in the recycle bin. You cannot set this parameter to the original name of the database.

        For example:

        obclient [(none)]> PURGE INDEX __recycle_$_100017_1673426335319344;
        
      • Purge all objects from the recycle bin

        obclient [(none)]> PURGE RECYCLEBIN;
        
    4. Execute the SHOW RECYCLEBIN statement 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.

    1. Log on to the sys tenant as the root user.

      Note that you must specify the corresponding fields in the following sample code based on your actual database configurations.

      obclient -h10.xx.xx.xx -P2883 -uroot@sys -p***** -A
      

      For more information, see Overview.

    2. 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';
      
    3. (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;
      

    References

    For more information about the recycle bin, see the following topics:

    • Overview

    • Enable or disable the recycle bin

    • View objects in the recycle bin

    • Restore objects from the recycle bin

    Previous topic

    Restore objects from the recycle bin
    Last

    Next topic

    Flashback queries
    Next
    What is on this page
    Manually purge the recycle bin
    Considerations
    Procedure
    Automatically purge the recycle bin
    References