定製資料表空間保留原則,定製保留原則

來源:互聯網
上載者:User

定製資料表空間保留原則,定製保留原則

在大型資料庫中,資源回收筒很大,垃圾很多,資料表空間查詢起來特別慢。為了防止意外操作,不可能每次drop表的時候加上perge,這時候垃圾越來越多,查資料表空間要等很久。這時,定製一個資料表空間保留原則就顯得非常有必要。下面將我的指令碼共用一下,加入job中便可自動清理。create or replace procedure lhj_delete_recyclebin ( preserve_date in number ) is/*預存程序名:lhj_delete_recyclebin編寫人:XXX功能:清理資源回收筒(預設保留7天)   purge table xx會把表對應的索引purge掉用法:   begin     lhj_delete_recyclebin(6);   end;*/v_sql varchar2 ( 1000 );cursor c ( v_preserve_date number ) isselect owner , original_name , droptime , type from dba_recyclebin where /*owner='GGS' and */ type = 'TABLE'and to_date ( droptime , 'yyyy-mm-dd hh24:mi:ss' )< trunc ( sysdate )- v_preserve_date order by 3 ;   --保留一周的表 可修改時間v_preserve_date number := preserve_date ;begin  if v_preserve_date is null then   v_preserve_date := 7 ;  end if ;  for x in c ( v_preserve_date ) loop    begin   v_sql := 'purge table ' || x.owner || '.' || x.original_name ;    --dbms_output.put_line(v_sql);    execute immediate v_sql ;    exception      when others then        rollback ;    end ;  end loop ;end ;

相關文章

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.