oracle 数据库
每天会形成一张表,如:test20101221;后面日期是变动的。
我需要写个批处理每天定时删除前一天的表,如:test20101220;那位高手给写个。

解决方案 »

  1.   

    你在形成新表的那里truncate掉前一天的表不更好吗?
      

  2.   

    1.在window写个定时任务,在linux使用contab在每天的凌晨去执行下面的脚本就可以了
    execute immediate 'drop table test'||to_char(sysdate-1,'yyyymmdd')
      

  3.   

    execute immediate 'drop table test'||to_char(sysdate-1,'yyyymmdd')
    报错:
    ORA-06550:第一行,第17列
    PLS-00103:出现符号 “drop table test”在需要下列之一时:
    := , < @ %
    ;
    符号":=" 被替换为“drop table test”后继续
      

  4.   

    --1/24每天凌晨删除
    declare
    jobno number;
    begin
    dbms_job.submit(jobno,'begin execute immediate 'drop table test'||to_char(sysdate-1,''yyyymmdd''); end;',sysdate,'trunc(sysdate+1)+1/24');
    commit;
    end;