OceanBase 支持回收站功能,通过回收站可以闪回已删除的表。默认回收站是开启的,回收站是否开启由租户变量 recyclebin 控制。

    开启/关闭回收站的语法是:

    1. set global recyclebin = ON | OFF ;

    修改回收站的开启状态后,只对后续新连接会话生效。

    • 示例:闪回被删除的表。
    1. obclient> drop table if exists t1;
    2. Query OK, 0 rows affected (0.02 sec)
    3. obclient> create table t1(id bigint not null primary key, gmt_create datetime not null default current_timestamp);
    4. Query OK, 0 rows affected (0.09 sec)
    5. obclient> insert into t1(id) values(1),(2),(3);
    6. Query OK, 3 rows affected (0.02 sec)
    7. Records: 3 Duplicates: 0 Warnings: 0
    8. obclient> select * from t1;
    9. +----+---------------------+
    10. | ID | GMT_CREATE |
    11. +----+---------------------+
    12. | 1 | 2020-02-28 09:47:07 |
    13. | 2 | 2020-02-28 09:47:07 |
    14. | 3 | 2020-02-28 09:47:07 |
    15. +----+---------------------+
    16. 3 rows in set (0.00 sec)
    17. obclient> drop table t1;
    18. Query OK, 0 rows affected (0.03 sec)
    19. obclient> show recyclebin\G
    20. *************************** 1. row ***************************
    21. OBJECT_NAME: __recycle_$_20200102_1585650066255592
    22. ORIGINAL_NAME: t1
    23. TYPE: TABLE
    24. CREATETIME: 2020-03-31 18:21:06.255716
    25. 1 row in set (0.03 sec)
    26. obclient> flashback table __recycle_$_20200102_1585650066255592 to before drop rename to t1;
    27. Query OK, 0 rows affected (0.02 sec)
    28. obclient> select * from t1;
    29. +----+---------------------+
    30. | ID | GMT_CREATE |
    31. +----+---------------------+
    32. | 1 | 2020-02-28 09:47:07 |
    33. | 2 | 2020-02-28 09:47:07 |
    34. | 3 | 2020-02-28 09:47:07 |
    35. +----+---------------------+