Oracle Database misoperation executed Delete, how do I recover the data? ___ Database

Source: Internet
Author: User
Tags rollback oracle database

As a programmer, database operation is necessary, but if the operation is wrong, generally will cause more serious consequences.

Today, accidentally, did a worried thing, will be using the organization of the wrong operation of the delete, suddenly the brain a little hypoxia, feeling a circle (I believe that no data backup and rollback experience of the small partners are such feelings), but a think, the database is generally supporting data rollback, Then look up the solution.

Because Oracle database is used, this is very good, because Oracle has flash-back functionality, instantaneous light.

There are two solutions to this problem:

One: Restore according to TIME:

1, query the current time of the database (the purpose is to check whether the database time is similar to your computer time, avoid time difference and restore the data to the wrong time point)

Select To_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual;

2, query delete data before the time point data

SELECT * from table name as of timestamp To_timestamp (' 2016-08-11 16:12:11 ', ' yyyy-mm-dd hh24:mi:ss ');

(If there is no data, the time will continue to advance)

3. Recover data (exciting moments)

Flashback table name to timestamp to_timestamp (' 2016-08-11 16:12:11 ', ' yyyy-mm-dd hh24:mi:ss ');

Successful, data recovery success;

However, there may be problems, such as error: ORA-08189: Do not enable row mobile function, can not flash back table;

Do not be afraid, this is very simple;

ALTER TABLE name enable row movement;

Then execute the above SQL again;

Second: Recover data from the database SCN

1, query the current database SCN number

Select CURRENT_SCN from v$database (switch to SYS user or system user query if not executed)

The current value of the query is: 91799986

2, reduce the SCN number query deleted table data (if no data continue to shrink SCN, because the database operation more than one person, the SCN number changes more, can be reduced a few number)

SELECT * from table name as of SCN 91799980;

3. Recover data

Flashback table name to SCN 91799980;

Restore completed. If error: ORA-08189: Do not enable row mobile function, can not flash back table;


The mood finally can calm down.

For other database misoperation execution Delete, there should also be a corresponding solution, for the time being not yet tried.


Related Article

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.