利用閃回query 恢復刪除的數據及存儲過程

今天不小心刪除了emp表的幾行數據,還好有閃回查詢這技術,不過當然還是要保證undo能夠用的情況下


scott@ORCL> select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7499 ALLEN      SALESMAN        7698 1981-02-20:00:00:00       1600        300         30
      7521 WARD       SALESMAN        7698 1981-02-22:00:00:00       1250        500         30
      7654 MARTIN     SALESMAN        7698 1981-09-28:00:00:00       1250       1400         30
      7698 BLAKE      MANAGER         7839 1981-05-01:00:00:00       2850                    30
      7782 CLARK      MANAGER         7839 1981-06-09:00:00:00       2450                    10
      7839 KING       PRESIDENT            1981-11-17:00:00:00       5000                    10
      7844 TURNER     SALESMAN        7698 1981-09-08:00:00:00       1500          0         30
      7876 ADAMS      CLERK           7788 1987-05-23:00:00:00       1100                    20
      7900 JAMES      CLERK           7698 1981-12-03:00:00:00        950                    30
      7902 FORD       ANALYST         7566 1981-12-03:00:00:00       3000                    20
      7934 MILLER     CLERK           7782 1982-01-23:00:00:00       1300                    10

11 rows selected.

利用閃回query 恢復

  1  insert into emp (
  2* select * from (select * from emp where empno in (7788,7369,7566))  as of timestamp  sysdate-5/24)
scott@ORCL> /

3 rows created.

scott@ORCL> commit;

Commit complete.

scott@ORCL> select count(*) from emp;

  COUNT(*)
----------
        14
既然遇到這個問題了就試試如何閃回我們寫的存儲過程或者函數吧。

  1  create or replace  procedure proc_1
  2  as
  3  begin
  4   dbms_output.put_line('Hello World');
  5* end;
wsx@ORCL> / 
利用閃回查詢找回文本內容,接下來只要利用找回的文本內容重新編譯即可
sys@ORCL> select text from dba_source as of timestamp sysdate-1/1440 where owner='WSX' and name='PROC_1';

TEXT
----------------------------------------------------------------------------------------------------
procedure proc_1
as
begin
 dbms_output.put_line('Hello World');
end;
end;

6 rows selected.


  1  create or replace procedure proc_1
  2  as
  3  begin
  4   dbms_output.put_line('Hello World');
  5* end;
wsx@ORCL> /


Procedure created.




發佈了37 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章