Skip to Main Content
  • Questions
  • Automatic refresh of materialized views

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Mikhail.

Asked: June 13, 2016 - 4:36 pm UTC

Last updated: June 14, 2016 - 4:16 am UTC

Version: 12.1.0.2.0

Viewed 1000+ times

You Asked

Hello Tom,

I am creating a materialized view and want it to refresh automatically daily at 2 AM.

So I am creating it using this approach:

create materialized view <mv_name> REFRESH NEXT (TRUNC(SYSDATE)+1+2/24) as
select ...

When oracle refreshes it automatically using complete refresh (I do not have MV logs), I want oracle to do truncate / insert /*+ append */.

I know that the MV can be refreshed the way I want by manually executing DBMS_MVIEW.refresh(<mv_name>, atomic_refresh=>false);

Is there an option when an MV is created to specify that this is how I want it to be refreshed automatically? If it exists, I could not find it.

Thank you,
Mikhail

and Connor said...

To my knowledge, there is nothing in the DDL to allow for this.

This is one of the reasons we often move such features to PL/SQL packages, because the greater flexibility. Think of dbms_stats. We did that because the continually extend the "analyze" command just would have got too unwieldy.


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Mikhail Gordon, June 14, 2016 - 1:44 pm UTC


More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library