刷新物化视图每分钟但仅在特定时间之间

时间:2016-08-09 07:04:37

标签: sql oracle11g oracle12c

我有一个物化视图,我希望在上午7点到晚上11点之间每隔15分钟刷新一次。

你能帮我解决相同的频率条款吗?

CREATE MATERIALIZED VIEW ABC
NOCOMPRESS LOGGING
BUILD IMMEDIATE
USING INDEX 
REFRESH COMPLETE ON DEMAND START WITH ----- NEXT -----
USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE
AS select * from PQR

最好的问候

1 个答案:

答案 0 :(得分:1)

您还可以创建调度程序作业:

BEGIN
  SYS.DBMS_SCHEDULER.CREATE_JOB
    (
       job_name        => 'DBAPER.MVW_TEST_REFRESH'
      ,start_date      => TO_TIMESTAMP_TZ('2011/09/02 00:00:00.000000 US/Central','yyyy/mm/dd hh24:mi:ss.ff tzr')
      ,repeat_interval => 'FREQ=DAILY;BYHOUR=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22;BYMINUTE=0,5,10,15,20,25,30,35,40,45,50,55'
      ,end_date        => NULL
      ,job_class       => 'DEFAULT_JOB_CLASS'
      ,job_type        => 'PLSQL_BLOCK'
      ,job_action      => 'BEGIN 
                            DBMS_MVIEW.REFRESH(''ABC'',''C'');
                            END;'
      ,comments        => 'Job to refresh materialized view ABC.'
    );
END;
/

这样您就有了更多的配置选项,例如排除夜间或周末等。