# 闪回操作

__*FLASHBACK TABLE*__

+ `FLASHBACK TABLE`: 在垃圾回收生命周期窗口之内还原被丢弃的表和数据

```8
tidb> select count(*), now() from test.r1;
+----------+---------------------+
| count(*) | now()               |
+----------+---------------------+
|        2 | ~!@2022-01-07 14:24:25@!~ |
+----------+---------------------+

tidb> ~!@drop table@!~ test.r1;

tidb> SELECT * FROM mysql.tidb WHERE variable_name = '~!@tikv_gc_safe_point@!~';
+--------------------+-------------------------+--------------------------------------------------------------+
| VARIABLE_NAME      | VARIABLE_VALUE          | COMMENT                                                      |
+--------------------+-------------------------+--------------------------------------------------------------+
| tikv_gc_safe_point | ~!@20220107-14:11:37 +0000@!~ | All versions after safe point can be accessed. (DO NOT EDIT) |
+--------------------+-------------------------+--------------------------------------------------------------+

tidb> ~!@flashback table@!~ test.r1 to r2;

tidb> select count(*) from test.r2;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
```
---------------------------------------------------------------------------------------

操作 1:你在 14:24 左右丢弃了表 test.r1。

操作 2:你发现 GC 安全点在 14:11 左右,因此过去 13 分钟内存在的任何数据仍由 MVCC 保留,你可以通过 FLASHBACK TABLE 将其恢复。

操作 3:闪回表。

操作 4:数据从 test.r2 查看。