Recover Oracle deleted data in a small note

Source: Internet
Author: User

Today, two tables of data are synchronized, and the table has its own association relationship. The new data has been deleted because no changes have been made to the synchronized table (a new number of data has been added, and there is a parent-child relationship between the data).

So I want to recover the following ways:

ALTER TABLE TableName the row movement attribute of the enable row movement;--startup table
Flashback table TableName to timestamp to_timestamp (' 2017-10-25 09:30:00 ', ' yyyy-mm-dd hh24:mi:ss ');--do flash back operation, Flash back to the time before the delete operation, restore the data

Then executes the second line, which fails because the flashback operation is in a transaction, and the parent-child relationship between the previously deleted data must be a parent record before the child record is restored, so at least two flashbacks are required. At this point you must know the exact time before the data was deleted. Use the system view provided by Oracle--v$sql or V$sqlarea to query the execution time of the DELETE statement:

SELECT * from V$sqlarea t where T.sql_text like ' DELETE from TABLENAME t where id% ' ORDER by T.last_active_time Desc;--lik The contents of e are case-sensitive

Query to results [copy out Sql_text column and last_active_time column]:

DELETE from Security_module T WHERE ID = ' 402899955f28120f015f284e2a6b01b2 ' 2017-10-25 9:53:39
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f285d55d701b7 ' 2017-10-25 9:53:35
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f2853c88701b3 ' 2017-10-25 9:53:35
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f285c983401b4 ' 2017-10-25 9:53:35
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f285d9c6501b8 ' 2017-10-25 9:53:35
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f285d009301b6 ' 2017-10-25 9:53:35
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f285ccc1501b5 ' 2017-10-25 9:53:35
DELETE from Security_module T WHERE ID = ' 402899955f28120f015f2838d52d01ad ' 2017-10-25 9:53:34

The result is just the previous DELETE statement, according to Last_active_time, the last execution is the first one, the data of the relationship between the order. Then do the flashback operation, set the flashback time: 2017-10-25-9:53:39,

The second time is set to: 2017-10-25 9:53:34, the data recovers smoothly.

Recover Oracle deleted data in a small note

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.