About Oracle misoperation - data rollback recovery after data is committed (flashback)

 

Reprinted from: http://www.cnblogs.com/WhyShang/

 

When operating the Oracle database today, when doing an Update data, I accidentally wrote a less where, look at this careless.

  As a result, all employee IDs have been updated to the same ID. This is a sad story.

  Because the job number is checked many times before it is stored in the database, the job number is unique~~

  Fortunately, I realized this after the update. Therefore, stop operating the database first. Think about whether the data after the database Commit can be rolled back! Searched online. Found that Oracle has a "flashback" function. For the specific concept of "flashback", please refer to Baidu Encyclopedia.

  If the data is committed multiple times, can it be flashed back? It seems impossible. Flashback can only temporarily store the most recent data operation. This is the same as memory. You can't find the previous year's data in memory. 

  Flashback execution steps: 

  1. Query the data before the latest update data (in order to determine whether it is the data before Commit)

   select * from account as of timestamp to_timestamp('2014-04-22 08:00:00', 'yyyy-mm-dd hh24:mi:ss');

  Where account is the table that was misoperated, ' 2014-04-22 08:00:00 ' means the time before the last update of the data,

  2. Enable the row movement function before the flashback operation ( flashback is not possible if it is not enabled )

   alter table account enable row movement;

  Where account represents the table that was misoperated 

  3. Execute the flashback statement:

   flashback table account to timestamp TO_TIMESTAMP('20140422 15:10:00','YYYYMMDD HH24:MI:SS');

  In this way, the misoperated data can be "find" back. haha~

  So, think again, Oracle has such a wonderful thing, does Sql Server have it? So I looked up the information and felt a little sad. Sql Server provides no such convenience. It seems that the only way to restore it is to use the log. . . .

  I was just reading an article about SQL data recovery. Mark it:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326021163&siteId=291194637