Oracle flash back technology restores misoperation data

Source: Internet
Author: User
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;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.