RECOVER
Name
RECOVER
Description
This statement is used to restore a previously deleted database, table or partition. It supports recover meta information by name or id, and you can set new name for recovered meta information.
You can get all meta informations that can be recovered by statement SHOW CATALOG RECYCLE BIN
.
grammar:
restore database by name
RECOVER DATABASE db_name;
restore table by name
RECOVER TABLE [db_name.]table_name;
restore partition by name
RECOVER PARTITION partition_name FROM [db_name.]table_name;
restore database by name and id
RECOVER DATABASE db_name db_id;
restore table by name and id
RECOVER TABLE [db_name.]table_name table_id;
restore partition by name and id
RECOVER PARTITION partition_name partition_id FROM [db_name.]table_name;
restore database by name, and set new db name
RECOVER DATABASE db_name AS new_db_name;
restore table by name and id, and set new table name
RECOVER TABLE [db_name.]table_name table_id AS new_db_name;
restore partition by name and id, and set new partition name
RECOVER PARTITION partition_name partition_id AS new_db_name FROM [db_name.]table_name;
illustrate:
- This operation can only restore meta information that was deleted in the previous period. Default is 1 day. (Configurable through the
catalog_trash_expire_second
parameter in fe.conf) - If you recover a meta information by name without id, it will recover the last dropped one which has same name.
- You can get all meta informations that can be recovered by statement
SHOW CATALOG RECYCLE BIN
.
Example
- Restore the database named example_db
RECOVER DATABASE example_db;
- Restore the table named example_tbl
RECOVER TABLE example_db.example_tbl;
- Restore the partition named p1 in table example_tbl
RECOVER PARTITION p1 FROM example_tbl;
- Restore the database named example_db with id example_db_id
RECOVER DATABASE example_db example_db_id;
- Restore the table named example_tbl with id example_tbl_id
RECOVER TABLE example_db.example_tbl example_tbl_id;
- Restore the partition named p1 with id p1_id in table example_tbl
RECOVER PARTITION p1 p1_id FROM example_tbl;
- Restore the database named example_db with id example_db_id, and set new name new_example_db
RECOVER DATABASE example_db example_db_id AS new_example_db;
- Restore the table named example_tbl, and set new name new_example_tbl
RECOVER TABLE example_db.example_tbl AS new_example_tbl;
- Restore the partition named p1 with id p1_id in table example_tbl, and new name new_p1
RECOVER PARTITION p1 p1_id AS new_p1 FROM example_tbl;
Keywords
RECOVER