Creating materialized view that refreshes every 5 min

后端 未结 2 984
失恋的感觉
失恋的感觉 2021-02-03 11:35

I created a materialized view that refreshed every 5 min but when I do insert and perform select on materialized view I get same old data? Do I need to refresh manually?

2条回答
  •  萌比男神i
    2021-02-03 12:00

    I have demonstrated in steps where a materialized view refresh after every one minute ,for having a mv which refresh after 5 minute use next(sysdate+5/1440)

    Step1:

    Create table temp (A int);
    

    Step2:

    Create Materialized view temp_mv
          refresh complete start with (sysdate) next  (sysdate+1/1440) with rowid
            as select * from temp;
    

    Step3:

    select count(*) from temp;
    
           COUNT(*)
          ----------
              0
    

    Step4:

    select count(*) from temp_mv;
    
           COUNT(*)
          ----------
              0
    

    Step5:

    begin
          for i in 1..10 loop
             insert into temp values (i+1);
          end loop;
    end;
    /
    

    Step6:

    commit;
    

    Step7:

    select count(*) from temp;
    
           COUNT(*)
         ----------
            10
    

    Step8:

    select count(*) from temp_mv;
    
           COUNT(*)
           ----------
              0
    

    Step9:

    select to_char(sysdate,'hh:mi') from dual;
    
           TO_CH
           -----
           04:28
    

    Step10:

    select to_char(sysdate,'hh:mi') from dual;
    
           TO_CH
            -----
           04:29
    

    Step11:

    select count(*) from temp;
    
          COUNT(*)
         ----------
            10
    

    Step12:

    select count(*) from temp_mv;
    
          COUNT(*)
          ----------
             10
    

提交回复
热议问题