During database operations, you may accidentally perform misoperations. For example, if you execute some problematic SQL statements, the data is damaged and needs to be restored, restore the entire table to a certain period of time. Flash back technology can be used in Oracle. 1. SELECT * FROMjf_test2; 2. add, delete, modify, and query the data in the original data table. Current Time: SELEC
During database operations, you may accidentally perform misoperations. For example, if you execute some problematic SQL statements, the data is damaged and needs to be restored, restore the entire table to a certain period of time. Flash back technology can be used in Oracle. 1. SELECT * FROM jf_test2; 2. add, delete, modify, and query the current time of the original data table: SELEC
During database operations, you may accidentally perform misoperations. For example, if you execute some problematic SQL statements, the data is damaged and needs to be restored, restore the entire table to a certain period of time. Flash back technology can be used in Oracle.
1. Data of the original data table
SELECT * FROM jf_test2;
2. add, delete, and modify operations
Query the current time: SELECTSYSDATEFROM dual;
Add, delete, and modify the jf_test2 table: SELECT * FROM jf_test2;
3. Determine the approximate time point of the Misoperation and retrieve the data of jf_test2 at the time point.
CREATETABLE jf_test2TempAS
SELECT * FROM jf_test2ASOFTIMESTAMP (to_date ('2017-04-01 15:03:00 ', 'yyyy-mm-dd hh24: mi: ss '));
Query jf_test2Temp:
SELECT * FROM jf_test2Temp;
4. Restore data
-- Restore false update
UPDATE jf_test2 t
SET t. name = (SELECT tt. nameFROM jf_test2temp ttWHERE tt. code = t. code)
WHEREEXISTS (SELECT * FROM jf_test2temp tttWHERE ttt. code = t. code );
-- Restore false delete
INSERTINTO jf_test2 (CODE, NAME)
SELECT tt. code, tt. name
FROM jf_test2temp tt
WHERENOTEXISTS (SELECT * FROM jf_test2 t WHERE t. code = tt. code );
-- Restore insert errors
DELETEFROM jf_test2 t
WHERENOTEXISTS (SELECT * FROM jf_test2temp ttWHERE tt. code = t. code );
Query jf_test2 again to see: SELECT * FROM jf_test2;