Oracle
 sql >> Database >  >> RDS >> Oracle

Creazione di una vista materializzata che si aggiorna ogni 5 min

Ho dimostrato nei passaggi in cui una vista materializzata si aggiorna dopo ogni one minute ,per avere un mv che si aggiorna dopo 5 minuti usa next(sysdate+5/1440)

Passaggio 1:

Create table temp (A int);

Passaggio 2:

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

Passaggio 3:

select count(*) from temp;

       COUNT(*)
      ----------
          0

Passaggio 4:

select count(*) from temp_mv;

       COUNT(*)
       ----------
          0

Passaggio 5:

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

Passaggio 6:

commit;

Passaggio 7:

select count(*) from temp;

      COUNT(*)
     ----------
        10

Passaggio 8:

select count(*) from temp_mv;

       COUNT(*)
       ----------
          0

Passaggio 9:

select to_char(sysdate,'hh:mi') from dual;

       TO_CH
       -----
       04:28

Passaggio 10:

select to_char(sysdate,'hh:mi') from dual;

       TO_CH
        -----
       04:29

Passaggio 11:

select count(*) from temp;

      COUNT(*)
     ----------
        10

Passaggio 12:

select count(*) from temp_mv;

      COUNT(*)
      ----------
         10