在数据库中有两个表,table1和table2,现要实现数据库自动隔一定的时间(比如2天)将table1的数据写到table2中去

解决方案 »

  1.   

    --创建 procedure
    create or replace procedure InsertToOtherTable is
    begin
      Insert into table2 select * from table1;
    end InsertToOtherTable;
    /
    --创建 job
    VARIABLE jobno number;
    begin
      sys.dbms_job.submit(job => :job,
                          what => 'InsertToOtherTable;',
                          next_date => sysdate,
                          interval => 'sysdate+2');
      commit;
    end;
      

  2.   

    变量写错了,应该如下:
    VARIABLE job number;
      

  3.   

    楼上正解,先创建一个存贮过程来实现将表table1的数据导入到table2
    然后再创建一个job,实现定时操作
      

  4.   

    create or replace procedure InsertToOtherTable is
    begin
      Insert into table2 select * from table1;
    end InsertToOtherTable;
    /
    这个有点问题,需要加一个限制条件:时间,如果没有时间限制的话,那么是查找Table1中所有的数据了。
    总体来说是正确的。