Oracle誤刪除資料的恢複方法

來源:互聯網
上載者:User

標籤:targe   height   move   data   lan   style   target   system   base   

 Oracle誤刪資料的恢複,分為兩種方法:SCN和時間戳記兩種方法恢複。

一、通過SCN恢複刪除且已提交的資料

 1、獲得當前資料庫的SCN號

 select current_scn from v$database; (切換到sys使用者或system使用者查詢) 

 查詢到的SCN號為:1499223

2、查詢當前SCN號之前的SCN

 select * from 表名 as of scn 1499220; (確定刪除的資料是否存在,如果存在,則恢複資料;如果不是,則繼續縮小scn號)

3、恢複刪除且已提交的資料

  flashback table 表名 to scn 1499220;

二、通過時間恢複刪除且已提交的資料

1、查詢當前系統時間

   select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) from dual;

2、查詢刪除資料的時間點的資料

   select * from 表名 as of timestamp to_timestamp(‘2013-05-29 15:29:00‘,‘yyyy-mm-dd hh24:mi:ss‘);  (如果不是,則繼續縮小範圍)

3、恢複刪除且已提交的資料

    flashback table 表名 to timestamp to_timestamp(‘2013-05-29 15:29:00‘,‘yyyy-mm-dd hh24:mi:ss‘);

    注意:如果在執行上面的語句,出現錯誤。可以嘗試執行 alter table 表名 enable row movement; //允許更改時間戳記

   找出刪除的資料:select * from 表名 as of timestamp to_timestamp(‘刪除時間點‘,‘yyyy-mm-dd hh24:mi:ss‘)   

   把刪除的資料重新插入原表: insert into 表名 (select * from 表名 as of timestamp to_timestamp(‘刪除時間點‘,‘yyyy-mm-dd hh24:mi:ss‘)); 

  select * from t_xxx as of timestamp (systimestamp - interval ‘10‘ minute)

參考:http://blog.chinaunix.net/uid-20845577-id-3866745.html

Oracle誤刪除資料的恢複方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.