创建物化视图,每天刷新记录 [英] Create Materialized view which refresh records on daily
问题描述
目前是我使用 REFRESH ON DEMAND 创建的物化视图,因此在这种情况下,我需要使用以下命令显式刷新 MV:
Currently the Materialized view which I had created using REFRESH ON DEMAND so in this case I need to refresh MV explicitly using below command:
BEGIN DBMS_MVIEW.REFRESH('MV_DATA'); END;
但是现在我需要每天刷新这个MV,所以有人可以帮忙写这个.我已经看到我们可以通过编写显式 Job 或在 MV 本身中使用 COMPLETE/FAST REFRESH 语句来刷新这个 MV.
But now I need to refresh this MV on daily basis so could anyone please help to write this. I have seen that we can refresh this MV using writing explicit Job or using COMPLETE/FAST REFRESH statement in MV itself.
提前致谢!
推荐答案
您需要使用 START WITH 和 NEXT Clause 创建物化视图
You need to create the materialized view using START WITH and NEXT Clause
create materialized view <mview_name>
refresh on demand
start with sysdate next sysdate + 1
as select ............
所以如果你想每天刷新mview,你需要保持按需刷新,并将下次刷新时间设置为sysdate + 1
.不过,您可以设置任何间隔.
So if you want to refresh mview daily, you need to keep it refresh on demand and set the next refresh time as sysdate + 1
. You can set any interval although.
完成此操作后,将创建物化视图并在 Oracle 中设置一个作业,该作业将每 24 小时刷新一次 mview (sysdate + 1)
.
Once you do this the materialized view is created and a job is set in Oracle that will refresh mview every 24 hrs (sysdate + 1)
.
有关如何执行此操作的更多信息,请关注 这个链接
For more information on how to do that, follow this link
这篇关于创建物化视图,每天刷新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!