Oracle 清库脚本

清库脚本一份

表dossier_group 的字段Dossier_Table存储的是要清空的表

DECLARE
tsql   varchar2(500);
countI number;
begin
  FOR I IN (select * from dossier_group ) LOOP
   select count(*) into countI from user_tables where table_name=upper(I.Dossier_Table) ;
   if countI > 0 then
    tsql:= 'TRUNCATE TABLE '||I.Dossier_Table ; 
    DBMS_OUTPUT.PUT_LINE(tsql);   
    execute immediate tsql;  
   end if;       
   
  END LOOP;
  EXCEPTION WHEN OTHERS THEN
  DBMS_OUTPUT.PUT_LINE(SQLERRM); 
end;

猜你喜欢

转载自zhuyufufu.iteye.com/blog/2089752