oracle materialized view refresh time

旧城冷巷雨未停 提交于 2019-12-04 06:59:29
SQL> alter session set nls_date_format = 'yyyy-mm-dd :hh24:mi:ss';

Session changed.

SQL> select sysdate from dual;

SYSDATE
--------------------
2008-12-19 :12:18:28

SQL> select (round(sysdate) + 1/24) + 1  from dual;

(ROUND(SYSDATE)+1/24
--------------------
2008-12-21 :01:00:00

To answer your first question (will this run once an hour?):

Nope, this will run once when you create it because of this clause:

START WITH sysdate+0 

Personally, I think the "+0" is extraneous, as now is now.

Then it will run tomorrow at 1 a.m., because of the following clause:

NEXT (round(sysdate) + 1/24) + 1

The "1/24" part calculates when 1 a.m. is, since Oracle dates are actually stored as numbers, with the decimal part indicating hours, minutes, etc. The syntax is just fine.

I'm not 100% sure that it's legal in a materialized view scheduling statement, but you might like to try the (arguably) more intuitive INTERVAL specification:

round(sysdate) + interval '1 1' day to hour

Other examples here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements003.htm#SQLRF00221

i think using

NEXT (trunc(sysdate) + 1/24) + 1

is more accurate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!