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:

  1. restore database by name

    1. RECOVER DATABASE db_name;
  2. restore table by name

    1. RECOVER TABLE [db_name.]table_name;
  3. restore partition by name

    1. RECOVER PARTITION partition_name FROM [db_name.]table_name;
  4. restore database by name and id

    1. RECOVER DATABASE db_name db_id;
  5. restore table by name and id

    1. RECOVER TABLE [db_name.]table_name table_id;
  6. restore partition by name and id

    1. RECOVER PARTITION partition_name partition_id FROM [db_name.]table_name;
  7. restore database by name, and set new db name

    1. RECOVER DATABASE db_name AS new_db_name;
  8. restore table by name and id, and set new table name

    1. RECOVER TABLE [db_name.]table_name table_id AS new_db_name;
  9. restore partition by name and id, and set new partition name

    1. 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

  1. Restore the database named example_db
  1. RECOVER DATABASE example_db;
  1. Restore the table named example_tbl
  1. RECOVER TABLE example_db.example_tbl;
  1. Restore the partition named p1 in table example_tbl
  1. RECOVER PARTITION p1 FROM example_tbl;
  1. Restore the database named example_db with id example_db_id
  1. RECOVER DATABASE example_db example_db_id;
  1. Restore the table named example_tbl with id example_tbl_id
  1. RECOVER TABLE example_db.example_tbl example_tbl_id;
  1. Restore the partition named p1 with id p1_id in table example_tbl
  1. RECOVER PARTITION p1 p1_id FROM example_tbl;
  1. Restore the database named example_db with id example_db_id, and set new name new_example_db
  1. RECOVER DATABASE example_db example_db_id AS new_example_db;
  1. Restore the table named example_tbl, and set new name new_example_tbl
  1. RECOVER TABLE example_db.example_tbl AS new_example_tbl;
  1. Restore the partition named p1 with id p1_id in table example_tbl, and new name new_p1
  1. RECOVER PARTITION p1 p1_id AS new_p1 FROM example_tbl;

Keywords

  1. RECOVER

Best Practice