假设:存在视图A,包含字段有a_1,a_2,a_3等注释:Create a temporary table for holding the data执行:sql> create table B as select * from A where 1<>1实现:现在要建一 定时触发器或存储过程,把视图A的数据复制到表B高手帮忙!

解决方案 »

  1.   

    create or replace procedure test
    is
    begin
      insert into B
        select * from A
          where not exists (select * from B where A.? = B.?);
    end test;触发器只有在表数据有变动时才能执行.你是视图A,不能用触发器
      

  2.   

    begin
      sys.dbms_job.submit(job => :job,
                          what => 'cp.s01;',
                          next_date => to_date('01-01-4000', 'dd-mm-yyyy'),
                          interval => 'SYSDATE + (600/(24*60*60))');
      sys.dbms_job.broken(job => :job,
                          broken => true,
                          next_date => to_date('01-01-4000', 'dd-mm-yyyy'));
      commit;
    end;
    10分钟一次,直到'01-01-4000'世界终结cp.s01过程
    create or replace package body cp as procedure s01 is        begin
                insert into b   a_1,a_2,a_3
                select a_1,a_2,a_3 from view;
                commit;
    exception
    when others then
    rollback;
    dbms_output.put_line(sqlerrm);
    end s01;
    end cp;
      

  3.   

    通过job去做,定时将数据复制过去,这里你要写一个过程,过程比较简单你自己很轻松就可以搞定了