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 - V3.2.4Enterprise Edition

    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. V3.2.4
    iconOceanBase Database
    SQL - V 3.2.4Enterprise Edition
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    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

    Recycle bin for databases, tables, and indexes

    Last Updated:2023-10-27 09:57:43  Updated
    Share
    What is on this page
    View objects in the recycle bin
    Background information
    Procedure
    Enable or disable the recycle bin
    Manually purge the recycle bin
    Automatically purge the recycle bin

    folded

    Share

    This topic describes how to manage the recycle bin for databases, tables, and indexes. This includes how to view objects in a recycle bin and how to enable, disable, and purge a recycle bin.

    View objects in the recycle bin

    Background information

    When you drop a database object:

    • If the recycle bin is enabled, the dropped object is then moved to the recycle bin and can be viewed in the recycle bin.

    • If the recycle bin is disabled, the object is not moved to the recycle bin and cannot be viewed in the recycle bin.

    Procedure

    1. Log on to the database as a tenant administrator.

    2. Execute the following statement to view objects in the recycle bin:

      obclient> SHOW RECYCLEBIN;
      +-------------------------------------+---------------+-------+----------------------------+
      | OBJECT_NAME                         | ORIGINAL_NAME | TYPE  | CREATETIME                 |
      +-------------------------------------+---------------+-------+----------------------------+
      | __recycle_$_100015_1637217861309360 | t1            | TABLE | 2021-11-18 14:44:21.310663 |
      +-------------------------------------+---------------+-------+----------------------------+
      1 row in set
      

      where

      • OBJECT_NAME indicates the name of an object in the recycle bin.

      • ORIGINAL_NAME indicates the original name of the object.

      • TYPE indicates the type of the object in the recycle bin.

        • In MySQL mode of OceanBase Database, the object type can be INDEX, TABLE, or DATABASE.

        • In Oracle mode of OceanBase Database, the object type can be INDEX or TABLE.

      • CREATETIME indicates the time when the object was placed in the recycle bin.

    Enable or disable the recycle bin

    After a tenant is created, the recycle bin is disabled by default. If the recycle bin is then enabled, dropped objects will be moved to the recycle bin.

    1. Log on to the database as a tenant administrator.

    2. Execute the following statement to view the state of the recycle bin:

      obclient> SHOW VARIABLES LIKE 'recyclebin';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | recyclebin    | OFF   |
      +---------------+-------+
      1 row in set
      
    3. Choose an appropriate method to enable or disable the recycle bin based on your business needs.

      • Execute the statements below to enable or disable the global recycle bin.

        The setting of the global recycle bin applies to the entire tenant, but not to previously created sessions. To apply the setting to an existing session, you need to log off and log on to the database again and then re-create the session.

        The recyclebin variable is Boolean and can be set to one of the following values:

        • on, 1, or true: indicates that the recycle bin is enabled.

        • off, 0, or false: indicates that the recycle bin is disabled.

        Syntax:

        obclient> SET GLOBAL recyclebin = on;
        
        obclient> SET GLOBAL recyclebin = off;
        

        or

        obclient> SET GLOBAL recyclebin = 1;
        
        obclient> SET GLOBAL recyclebin = 0;
        

        or

        obclient> SET GLOBAL recyclebin = true;
        
        obclient> SET GLOBAL recyclebin = false;
        
      • Execute the statements below to enable or disable the session-level recycle bin.

        The setting of the session-level recycle bin only applies to the current session.

        Syntax:

        obclient> SET @@recyclebin = on;
        
        obclient> SET @@recyclebin = off;
        

        or

        obclient> SET @@recyclebin = 1;
        
        obclient> SET @@recyclebin = 0;
        

        or

        obclient> SET @@recyclebin = true;
        
        obclient> SET @@recyclebin = false;
        

    Manually purge the recycle bin

    Frequently dropping and re-creating database objects will generate a large amount of data in the recycle bin, which can be cleaned using the PURGE statement.

    Notice

    The PURGE statement will delete an object and any objects that are subordinate to it. For example, purging a database will delete not only the database itself but also the tables and indexes in it.

    Before executing the PURGE statement, you can view the dropped objects in the recycle bin. After executing the PURGE statement, the information about the objects will no longer be available in the recycle bin of OceanBase Database, and the actual data will eventually be garbage collected.

    If an upper-level object is purged, the associated lower-level objects in the current recycle bin will also be purged.

    The procedure for manually purging the recycle bin is as follows:

    1. Log on to the database as a tenant administrator.

    2. Execute the following statements to purge the recycle bin.

      The object_name parameter in the following statements indicates the name of the schema object in the recycle bin. To obtain this name, execute the SHOW RECYCLEBIN statement.

      • Physically purge a database from the recycle bin

        obclient> PURGE DATABASE object_name;
        
      • Physically purge a table from the recycle bin

        obclient> PURGE TABLE object_name;
        
      • Physically purge an index from the recycle bin

        obclient> PURGE INDEX object_name;
        
      • Purge the entire recycle bin

        obclient> PURGE RECYCLEBIN;
        

    Automatically purge the recycle bin

    OceanBase Database supports automatically cleaning up expired schema objects in the recycle bin through the cluster-level parameter recyclebin_object_expire_time. Its default value 0s.

    • If the value is 0s, the schema objects in the recycle bin are not automatically purged.

    • If the value is not 0s, the schema objects that have been put 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.

    The procedure for enabling the automatic purge feature is as follows:

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

    2. Execute the following statement to enable the automatic purge feature and purge the schema objects that were put in the recycle bin, for example, seven days ago:

      obclient> ALTER SYSTEM SET recyclebin_object_expire_time = '7d';
      
    3. (Optional) Execute the following statement to check whether the objects that meet the specified conditions have been purged from the recycle bin:

      obclient> SHOW RECYCLEBIN;
      

    Previous topic

    Objects supported by the recycle bin
    Last

    Next topic

    Recycle bin for tenants
    Next
    What is on this page
    View objects in the recycle bin
    Background information
    Procedure
    Enable or disable the recycle bin
    Manually purge the recycle bin
    Automatically purge the recycle bin