oracle剛刪完的資料找回

2021-08-31 10:57:56 字數 1124 閱讀 5436

刪除資料前表中記錄

1> select t.*, t.rowid from vt_temp_test;

1 1 2 3.00 4.00

2 5 6 7.00 8.00

3 9 10 11.00 12.00

4 13 14 15.00 16.00

記錄原資料完整時間點

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

1 2009-01-08 09:23:53

刪除表中記錄

3> delete from vt_temp_test;

找回原資料完整時間點資料

4> select * from vt_temp_test as of timestamp to_timestamp('2009-01-08 09:23:53', 'yyyy-mm-dd hh24:mi:ss');

1 1 2 3.00 4.00

2 5 6 7.00 8.00

3 9 10 11.00 12.00

4 13 14 15.00 16.00

插入丟失資料到原表

5> insert into vt_temp_test select * from vt_temp_test as of timestamp to_timestamp('2009-01-08 09:23:53', 'yyyy-mm-dd hh24:mi:ss');

驗證資料恢復情況

6> select * from vt_temp_test

1 1 2 3.00 4.00

2 5 6 7.00 8.00

3 9 10 11.00 12.00

4 13 14 15.00 16.00

---- 此時表明資料已完全恢復到原資料完整時間點的資料 ----

#### 注:當執行 truncate table vt_temp_test 時,就無法恢復資料,查詢當時資料會報錯:ora-01466 unable to read table - table definition has changed。drop table vt_temp_test則更不可恢復 ####

如果是mysql:

mysql沒測試是否好使

找回oracle中刪除的資料

select dbms flashback.get system change number from dual 查詢當前scn號 如果不知道刪除之前的scn號,可以進行閃回查詢 即,數字一直減小,直到找到為止 select count from table1 as of scn 205125720...

oracle找回被刪除的資料

oracle中如果進行裡的delete如果想要恢復 例如檢視某一張表 select from vts users 發現有2條資料 然後執行刪除表資料操作 delete from vts users 這是檢視scn資料 select dbms flashback.get system change n...

Oracle資料刪除後找回

檢視當前scn數值 select dbms flashback.get system change number from dual scn與時間的對應關係 select to char sysdate,yyyy mm dd hh24 mi ss to char dbms flashback.get...