# Flashback Table

+ Query the DDL operation timestamp
  + `admin show ddl jobs;` 

+ Set tidb_snapshot
  + `set @@tidb_snapshot="yyyy-mm-dd hh:mi:ss";` 

+ Execute Flashback command to recover data (for Drop and Truncate)
  + `FLASHBACK TABLE target_table_name [TO new_table_name]` 

------------------------------------------------------------

Using the FLASHBACK TABLE statement to recover tables and data dropped by DROP or TRUNCATE is simple. The syntax is as follows:

1. Query the DDL operation timestamp
admin show ddl jobs;

2. Set tidb_snapshot
set @ @tidb_snapshot ="yyyy-mm-dd hh:mi:ss”;

3. Execute Flashback command to recover data
FLASHBACK TABLE target_table_name [TO new_table_name]

When TiDB drop table, it actually only deletes the metadata of the table, and writes the table data (row data and index data) that needs to be deleted to the mysql.gc_delete_range table. The GC worker in the TiDB background periodically fetches keys that exceed the GC lifetime related range from the mysql.gc_delete_range table to delete them.

Therefore, FLASHBACK TABLE only needs to recover the metadata of the table and delete the corresponding row records in the mysql.gc_delete_range table before the GC worker deletes the table data. The metadata of the recover table can be implement by snapshot read of TiDB.