oracle表資料誤刪還原

2021-06-06 07:24:51 字數 1682 閱讀 2174

一、如果是剛剛刪除,那麼有兩方法:    首先用show parameter undo;命令檢視當時的資料庫引數undo_retention設定。

顯示如下:

undo_management                       string       auto

undo_retention                              integer     10800

undo_suppress_errors                  boolean      false

undo_tablespace                           string       undotbs1

undo_retention(保持力),10800單位是秒。即3個小時。

修改預設的undo_retention引數設定:

alter system set undo_retention=10800 scope=both;

方法1,通過oracle提供的回閃功能:

exec dbms_flashback.enable_at_time(to_date('2007-07-23 10:21:00','yyyy-mm-dd hh24:mi:ss'));

set serveroutput on

declare r_temp hr.job_history%rowtype;

cursor c_temp is select * from hr.job_history;

begin

open c_temp;

dbms_flashback.disable;

loop

fetch c_temp into r_temp;

exit when c_temp%notfound;

insert into hr.job_history(employee_id,job_id,start_date,end_date) values (r_temp.employee_id,r_temp.job_id,r_temp.start_date,r_temp.end_date);

commit;

end loop;

close c_temp;

end;

方法2,insert into hr.job_history

select * from hr.job_history as of timestamp to_timestamp('2007-07-23 10:20:00', 'yyyy-mm-dd hh24:mi:ss');

這種方法簡單,容易掌握,功能和上面的一樣時間為你誤操作之前的時間,最好是離誤操作比較近的,因為oracle儲存在回滾保持段裡的資料時間有一定的時間限制由undo_retention 這個引數值決定。

二、如果是刪除一段時間了,但你有比較新的資料庫備份,就通過備份來恢復。新建乙個庫,把備份還原上去,匯出表資料,再匯入到現在用的庫中去。

三、如果刪除一段時間了,並且無備份,但是資料在寫入表的時候同時會寫入其它一些關聯表的話,那麼就嘗試通過寫sql語句從其它表取資料出來insert到被刪除的表中。

四、恢復到備份表中

create table tablename_bak as

select * from tablename as of timestamp to_timestamp('20081126 103435','yyyymmdd hh24miss');

還原誤刪資料筆記

要你沒有向刪除檔案的分割槽寫入檔案,就還有機會將刪除的檔案恢復。如資料已被覆蓋,可到專業的資料恢復公司求助,他們有高階的儀器和高超的技術能恢復多次被覆蓋的檔案,這是一般人不能辦到的。使用系統自帶的系統還原的方法 系統自帶的系統還原 開始 程式 附件 系統工具 系統還原 點選 恢復我的計算機到乙個較早...

oracle 表資料 誤刪時 資料恢復

通過時間恢復刪除資料 alter table drugusage enable row movement 開啟行遷移 select from drugusage as of timestamp to timestamp 2016 06 02 12 00 47 yyyy mm dd hh24 mi s...

oracle恢復誤刪表

一 表的恢復 對誤刪的表,只要沒有使用purge永久刪除選項,那麼從flash back區恢復回來希望是挺大的。一般步驟有 1 從flash back裡查詢被刪除的表 select from recyclebin 2.執行表的恢復 flashback table tb to before drop,...