oracle 刷新现有的物化视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25997931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Refreshing an existing materialized View
提问by Cool_Oracle
I created a materialized view with the following information.
我创建了一个包含以下信息的物化视图。
CREATE MATERIALIZED VIEW EMPLOYEE_INFO
AS
SELECT * FROM EMPLOYEE_TABLE WHERE LOCATION = 'Brazil'
I did not add any refresh interval to this MV initially. Now, I need to refresh this MV everyday at 0000HRS. Will the following command help me to alter it for everyday at 0000HRS?
我最初没有给这个 MV 添加任何刷新间隔。现在,我需要每天0000HRS刷新这个MV。以下命令会帮助我每天在 0000HRS 更改它吗?
ALTER MATERIALIZED VIEW EMPLOYEE_INFO
REFRESH COMPLETE
START WITH SYSDATE
In case, I need to refresh it for every 6 hours, how do I perform it? Is it possible?
如果我需要每 6 小时刷新一次,我该如何执行?是否可以?
回答by Rimas
For periodic refresh you must use NEXT
clause. To refresh everyday at 00:00:
对于定期刷新,您必须使用NEXT
子句。每天 00:00 刷新:
ALTER MATERIALIZED VIEW EMPLOYEE_INFO
REFRESH COMPLETE
NEXT TRUNC(SYSDATE) + 1
To refresh every 6 hours:
每 6 小时刷新一次:
ALTER MATERIALIZED VIEW EMPLOYEE_INFO
REFRESH COMPLETE
NEXT SYSDATE + 6/24
From documentation(ALTER MATERIALIZED VIEW):
从文档(ALTER MATERIALIZED VIEW):
START WITH Clause
Specify START WITH date to indicate a date for the first automatic refresh time.
NEXT Clause
Specify NEXT to indicate a date expression for calculating the interval between automatic refreshes.
Both the START WITH and NEXT values must evaluate to a time in the future. If you omit the START WITH value, then Oracle Database determines the first automatic refresh time by evaluating the NEXT expression with respect to the creation time of the materialized view. If you specify a START WITH value but omit the NEXT value, then Oracle Database refreshes the materialized view only once. If you omit both the START WITH and NEXT values, or if you omit the alter_mv_refresh entirely, then Oracle Database does not automatically refresh the materialized view.
从条款开始
指定 START WITH 日期以指示第一次自动刷新时间的日期。
下一条
指定 NEXT 以指示用于计算自动刷新间隔的日期表达式。
START WITH 和 NEXT 值都必须计算为未来的时间。如果省略 START WITH 值,则 Oracle 数据库通过评估与物化视图的创建时间相关的 NEXT 表达式来确定第一次自动刷新时间。如果指定 START WITH 值但省略 NEXT 值,则 Oracle 数据库仅刷新实例化视图一次。如果同时省略 START WITH 和 NEXT 值,或者完全省略 alter_mv_refresh,则 Oracle 数据库不会自动刷新物化视图。
At the time of the next automatic refresh, Oracle Database refreshes the materialized view, evaluates the NEXT expression to determine the next automatic refresh time, and continues to refresh automatically.
在下一次自动刷新时,Oracle 数据库刷新物化视图,评估NEXT 表达式以确定下一次自动刷新时间,并继续自动刷新。