Skip to main content

Purge the recycle bin

Frequent deletion and recreation of database objects will generate a large amount of data in the recycle bin. You can purge the recycle bin to clean up this data.

Purging the recycle bin can be done manually or automatically.

Manually purge the recycle bin

You can use the PURGE command to manually purge the recycle bin.

Considerations

  • The Purge operation will delete the object and all objects that depend on it (Database > Table > Index). For example, purging a database will delete the database and all tables and table indexes associated with it.

  • If the parent object is purged, the associated child objects in the recycle bin will also be purged.

  • Before executing the Purge operation, it is recommended to verify the objects to be purged in the recycle bin. After the Purge operation is executed, the information of the objects will no longer be queryable in the seekdb recycle bin, and the real data will eventually be garbage-collected.

Procedure

  1. Log in to seekdb as the administrator root.

    The connection example is as follows. Please connect to the database based on your actual environment.

    mysql -h127.0.0.1 -uroot -P2881
  2. Execute the SHOW RECYCLEBIN statement to obtain the names of the objects in the recycle bin.

    SHOW RECYCLEBIN;
    +--------------------------------+---------------+----------+----------------------------+
    | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
    +--------------------------------+---------------+----------+----------------------------+
    | __recycle_$_1_1765784426825016 | test_db | DATABASE | 2025-12-15 15:40:26.825340 |
    | __recycle_$_1_1765785669490408 | tbl1 | TABLE | 2025-12-15 16:01:09.491488 |
    +--------------------------------+---------------+----------+----------------------------+
    1 row in set (0.003 sec)
  3. Based on your business needs, select the appropriate scenario to purge the recycle bin.

    • Physically purge the specified database from the recycle bin.

      PURGE DATABASE object_name;

      object_name represents the name of the schema object in the recycle bin. The original name cannot be used.

      Example:

      PURGE DATABASE __recycle_$_1_1765784426825016;
    • Physically purge the specified table from the recycle bin.

      PURGE TABLE object_name;

      object_name represents the name of the schema object in the recycle bin. The original name can be used. If the original name is used and there are multiple objects with the same original name in the recycle bin, the one that entered the recycle bin earliest will be purged.

      Example:

      PURGE TABLE __recycle_$_1_1765785669490408;
    • Physically purge the specified index table from the recycle bin.

      PURGE INDEX object_name;

      object_name represents the name of the schema object in the recycle bin. The original name cannot be used.

      Example:

      PURGE INDEX __recycle_$_100017_1673426335319344;
    • Thoroughly purge all objects from the recycle bin.

      PURGE RECYCLEBIN;
  4. After the command is executed successfully, you can execute the SHOW RECYCLEBIN statement again to confirm whether the objects in the recycle bin have been successfully purged.

    SHOW RECYCLEBIN;

Automatically purge the recycle bin

seekdb supports automatically purging expired schema objects in the recycle bin by configuring the recyclebin_object_expire_time parameter. The default value is 0s. Here's what the values mean:

  • When the value is 0s, automatic Purge of the recycle bin is disabled.

  • When the value is not 0s, schema objects that entered the recycle bin a certain period of time ago will be purged.

For more information about the recyclebin_object_expire_time parameter, see recyclebin_object_expire_time.

  1. Log in to seekdb as the root user.

    The connection example is as follows. Please connect to the database based on your actual environment.

    mysql -h127.0.0.1 -uroot -P2881
  2. Execute the following statement to view the automatic purge strategy of the recycle bin.

    SHOW PARAMETERS LIKE 'recyclebin_object_expire_time';

    The query result is as follows:

    +---+-----------+-------+-------------+--------------+---------+---------+
    | name | data_type | value | info | edit_level | default_value | isdefault |
    +-----+--------------+---------+---------+-------------------+---------------+-----------+
    | recyclebin_object_expire_time | TIME | 0s | recyclebin object expire time, default 0 that means auto purge recyclebin off. Range: [0s, +∞) | DYNAMIC_EFFECTIVE | 0s | 1 |
    +------+--------------+---------+---------+-------------------+---------------+-----------+
    1 row in set (0.003 sec)
  3. Execute the following statement to enable the automatic purge of the recycle bin and specify the objects to be purged.

    Enable the automatic purge of the recycle bin and purge schema objects that entered the recycle bin 7 days ago. Example statement:

    ALTER SYSTEM SET recyclebin_object_expire_time = '7d';
  4. (Optional) After the operation is completed, you can execute the following statement to confirm whether the objects in the recycle bin that meet the criteria have been purged.

    SHOW RECYCLEBIN;

References

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