Oracle基礎教程:恢複當天刪除的資料

來源:互聯網
上載者:User

我誤刪了資料庫,老大很不爽,命我再30分鐘之內恢複,情急之下,寫了一個預存程序,適用於恢複當天刪除了表而沒有記住表的名稱。

只需要傳入當天的時間,調用一下就ok了。

  1. 預存程序如下:   
  2.   create or replace procedure proc_databack (deletetime in varchar2)   
  3.   as  
  4.   --把當天已經刪除的資訊查詢出來放入遊標   
  5.   cursor mycursor is(select  object_name   from recyclebin  where droptime like deletetime);   
  6.   temp_emp    varchar2(2000);   
  7.   vflash_back   varchar2(2000);   
  8.   begin  
  9.     open mycursor;   
  10.     loop   
  11.     fetch mycursor  into temp_emp;   
  12.     exit when mycursor%notfound;   
  13.    --構建恢複語句   
  14.     vflash_back:='flashback table "'||temp_emp||'"  to  before drop';   
  15.      --迴圈恢複被刪除的表,直到全部恢複完成   
  16.     execute immediate vflash_back;   
  17.     end loop;   
  18.     close mycursor;   
  19. end;   
  20.   
  21. --調用預存程序   
  22. --比如今天是2011-12-02,那麼寫法如下:   
  23. /*   
  24. declare  
  25. time varchar2(20);   
  26. begin  
  27. time:='2011-12-02%';   
  28. proc_databack (time);   
  29. end;   
  30. */  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.