# Flashback Operation

__*FLASHBACK TABLE*__

+ `FLASHBACK TABLE` statement restores discarded tables and data within the garbage collection lifecycle window

```
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 |
+----------+
```
----------------------------------------------------------------------------------------------------------------------------

Statement 1: Drop table `test.r1` around 14:24.

Statement 2: Verify that GC safe point is around 14:11, so any data that existed in the last 13 minutes is still kept by MVCC, you can bring it back by `FLASHBACK TABLE` statement.

Statement 3: Execute `FLASHBACK TABLE` operation.

Statement 4: The data previously in table `test.r1` is restored to table `test.r2`.
