描述
用于从回收站中恢复被删除的DATABASE。
前置条件
回收站需要处于开启状态,可以通过show variables like 'recyclebin';
来查看回收站是否开启。
OceanBase(admin@test)> show variables like 'recyclebin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| recyclebin | ON |
+---------------+-------+
1 row in set (0.00 sec)
果回收站处于关闭状态,可以通过set recyclebin = on;
来开启。回收站中的表没有被实际删除,仍然会占用资源,如果需要彻底删除,可以执行purge recyclebin;
格式
FLASHBACK DATABASE object_name TO BEFORE DROP [RENAME TO db_name];
参数解释
参数 | 解释 |
object_name | 指定要恢复的object名称,不支持指定DATABASE名称。恢复DATABASE时,也会将DATABASE下面的表、索引等都恢复出来。 |
RENAME to | 恢复时将DATABASE重命名。 |
示例
- 从回收站中恢复删除的DATABASE。
OceanBase(admin@test)> create database da;
Query OK, 1 row affected (0.03 sec)
OceanBase(admin@test)> drop database da;
Query OK, 0 rows affected (0.04 sec)
OceanBase(admin@test)> show recyclebin;
+--------------------------------------------------+---------------+----------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------------------------+---------------+----------+----------------------------+
| __recycle_$_1_1099511628829_18446744073709551615 | da | DATABASE | 2017-10-20 17:36:15.838771 |
+--------------------------------------------------+---------------+----------+----------------------------+
1 row in set (0.02 sec)
OceanBase(admin@test)> flashback database __recycle_$_1_1099511628829_18446744073709551615 to before drop;
Query OK, 0 rows affected (0.03 sec)