OceanBase 支持回收站功能,通过回收站可以闪回已删除的表。默认回收站是开启的,回收站是否开启由租户变量 recyclebin 控制。
开启/关闭回收站的语法是:
set global recyclebin = ON | OFF ;
修改回收站的开启状态后,只对后续新连接会话生效。
- 示例:闪回被删除的表。
obclient> create table t1(id number not null primary key, gmt_create date not null default sysdate);
Query OK, 0 rows affected (0.09 sec)
obclient> insert into t1(id) values(1),(2),(3);
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0
obclient> select * from t1;
+----+---------------------+
| ID | GMT_CREATE |
+----+---------------------+
| 1 | 2020-04-02 18:20:49 |
| 2 | 2020-04-02 18:20:49 |
| 3 | 2020-04-02 18:20:49 |
+----+---------------------+
3 rows in set (0.00 sec)
obclient> drop table t1;
Query OK, 0 rows affected (0.03 sec)
obclient> show recyclebin;
+-------------------------------------+------------------------------------+-------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+-------------------------------------+------------------------------------+-------+----------------------------+
| RECYCLE_$_20200102_1585822884952336 | T1 | TABLE | 2020-04-02 18:21:24.952475 |
+-------------------------------------+------------------------------------+-------+----------------------------+
1 rows in set (0.01 sec)
obclient> flashback table RECYCLE_$_20200102_1585822884952336 to before drop rename to t1;
Query OK, 0 rows affected (0.02 sec)
obclient> select * from t1;
+----+---------------------+
| ID | GMT_CREATE |
+----+---------------------+
| 1 | 2020-04-02 18:20:49 |
| 2 | 2020-04-02 18:20:49 |
| 3 | 2020-04-02 18:20:49 |
+----+---------------------+
3 rows in set (0.00 sec)