How Oracle retrieves the table records that have been deleted ____oracle

Source: Internet
Author: User

Sometimes we accidentally delete the important records in the database table (EMP), how to get it back, look at the example below you will understand.

One day, 10 o'clock, John accidentally deletes an important record of the EMP in the database table and commits it, and there is no other backup data at this time,

He was very frightened, 10:05 his colleagues, that is, I appeared in and his relaxed chat to give the following solutions, ha ha ...

Me: What's wrong?

Zhang: I have to delete some of the data EMP table, I do not know how to delete the few ...

Me: Don't worry, it's probably time to delete it.

Zhang: About 10 o ' clock

Me: Well, it's 10:05 now, that's 5 minutes ago, not more than 6 minutes.

Zhang: How to do ah, how do I put that a few data to get back Ah, the afternoon customers have to wait to do the data demo

Me: Calm down, let me think ... Well, if we can retrieve the data that was not deleted 6 minutes ago, the problem will be solved.

Retrieve the original data 6 minutes ago (Note that 6 minutes must be operation distance from the current active time zone, if greater than 5 minutes less than 6 minutes,

There is no operation in the middle that can only adhere to the small principle of writing 5, or will report ora-01466: Unable to read data-table definition changed)

   SELECT * from emp as of timestamp sysdate-6/1440

Me: Now you can delete the original table Oh, just create a backup table.

   CREATE TABLE EMP as (SELECT * from emp as of timestamp sysdate-6/1440);

Zhang: This is a good way, but our company has rules, the table can not be deleted with the table, or my performance bonus will be all gone.

Zhang: Can you delete the original table on the basis of the retrieved records inserted into the original table

Me: Let me, think about ... Have a.

Me: We can do worse, find deleted records = 6 minutes before the original data-now the records in the table, and then insert the original table, submit

INSERT INTO EMP
SELECT *-Records  deleted 6 minutes ago from
(SELECT *-6 minutes ago deleted from EMP as of
     timestamp sysdate-6/1440 --6 minutes ago Raw data
     minus-minus
     select * from EMP-now records in table

Zhang: Yes ... It's OK, thanks.

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.