Skip to main content

Recover from Recycle Bin

Data Lifecycle​

When a user executes the DROP DATABASE/TABLE/PARTITION command without FORCE, Doris moves the deleted database, table, or partition to the recycle bin. The RECOVER command can be used to restore all data of the deleted database, table, or partition from the recycle bin, making them visible again.

Recover from Recycle Bin​

In order to avoid disasters caused by misoperation, Doris supports data recovery of accidentally deleted databases, tables, and partitions. After dropping a table or database, Doris does not physically delete the data immediately. Instead, it is moved to the trash for a certain period of time (the default is 1 day, which can be configured through the catalog_trash_expire_second parameter in fe.conf). The administrator can use the RECOVER command to restore accidentally deleted data.

Note: If the deletion was performed using DROP FORCE, the data will be immediately deleted and cannot be recovered.

Query Recycle Bin​

You can query the Recycle Bin with the following command:

SHOW CATALOG RECYCLE BIN [WHERE NAME [= "name" | LIKE "name_matcher"]];

For more detailed syntax and best practices, please refer to the SHOW-CATALOG-RECYCLE-BIN command manual, You can also type help SHOW CATALOG RECYCLE BIN on the MySql client command line for more help.

Start Data Recovery​

To recover deleted data, you can use the following commands:

  1. Recover the database named example_db:
RECOVER DATABASE example_db;
  1. Recover the table named example_tbl:
RECOVER TABLE example_db.example_tbl;
  1. Recover partition named p1 in table example_tbl:
RECOVER PARTITION p1 FROM example_tbl;

For more detailed syntax and best practices used by RECOVER, please refer to the RECOVER command manual, You can also type HELP RECOVER on the MySql client command line for more help.