ORACLE恢複刪除的資料

來源:互聯網
上載者:User

標籤:

---正在執行的

select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT
  from v$session a, v$sqlarea b 
where a.sql_address = b.address 
---執行過的
select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT
  from v$sqlarea b
where b.FIRST_LOAD_TIME between ‘2009-10-15/09:24:47‘ and
       ‘2009-10-15/09:24:47‘ order by b.FIRST_LOAD_TIME 
(此方法好處可以查看某一時間段執行過的sql,並且 SQL_FULLTEXT 包含了完整的 sql 語句)

我用了執行過的語句查詢某一時間段自己執行過的sql語句

轉載自:http://blog.163.com/[email protected]/blog/static/6251585020091171047923/

刪除資料前表中記錄
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_test1 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則更不可恢複 ####轉載自:http://blog.chinaunix.net/uid-16861721-id-2857492.html我自己的用法:首先查詢某一時間段,自己執行過的sql語句(主要是我delete了一條資料,想要找回)1、select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT
  from v$sqlarea b
where b.FIRST_LOAD_TIME between ‘2009-10-15/09:24:47‘ and
       ‘2009-10-15/09:24:47‘ order by b.FIRST_LOAD_TIME 然後,返回的資料中有我執行過的delete語句,和執行語句的具體時間然後,我根據執行語句的具體時間找尋自己這個時間的資料2、select * from vt_temp_test as of timestamp to_timestamp(‘2009-01-08 09:23:53‘, ‘yyyy-mm-dd hh24:mi:ss‘); 然後,將資料插入到原表3、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‘);4、驗證資料恢複情況select * from vt_temp_test

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.