想在数据库服务器上写个脚本每天自动清除数据库中一张表的数据,怎么写这个脚本呢?

解决方案 »

  1.   

    使用oracle job 定时执行你得存储过程,你得存储过程内执行truncate
    http://www.bitscn.com/oracle/optimize/200604/19366.htmlhttp://www.cnblogs.com/liunx/archive/2008/04/09/1145173.html
      

  2.   

    例如每分钟执行一次
    create table test1(s varchar2(100));
    insert into test1 values('1');create or replace procedure sp_test is
    begin
      execute immediate 'truncate table test1';
    end;
    /
    declare   
      jobno number;   
    begin   
      dbms_job.submit(jobno,'sp_test;',sysdate,'sysdate+1/1440');  
      commit;   
      dbms_job.run(jobno);
    end;
    /
      

  3.   

    也可以使用系统的定时任务执行一个批处理文件,批处理文件中调用sqlplus执行truncate !
      

  4.   

    在服务器上我们是先输入
    sqlplus 用户名/密码
    然后再输入
    SQL>truncate table a;
    再输入
    SQL>commit;
    如果写到shell里怎么实现呢?