Materialized view refresh every day at 6am.

Posted on 2014-02-14
Last Modified: 2014-02-17
Can someone help me out?

Trying to figure out a couple of things.

First, I have a materialized view, i need to refresh everyday at 6am.

create materialized view sometable as
select * from sometable

Open in new window

Complete refresh, the remote database is non-oracle.


Can i have multiple materialized views refresh at the same time at 6am? or should i do them one after another. In that case, how can I start the materialized view refresh to execute one after another?

Question by:FutureDBA-
  • 3
  • 2
  • 2
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39860753

Check out the NEXT clause on the materialized view.

Try something like:
create materialized view sometable as
build immediate
refresh fast
start with trunc(sysdate)+6/24
next trunc(sysdate)+6/24
select * from sometable

Open in new window

I doubt they would all run at the exact same time.  It would also put a strain on the system.  I would try to stretch them out.
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39860758
Forgot this:
>>how can I start the materialized view refresh to execute one after another?

Don't set the NEXT value and create a stored procedure to call REFRESH then dbms_scheduler to call the procedure.

Author Comment

ID: 39860768
So Can i create this procedure

CREATE PROCEDURE sometable_dailyrefresh as 
DBMS_SNAPSHOT.REFRESH( '"CDC"."sometable"','C');
DBMS_SNAPSHOT.REFRESH( '"CDC"."othertable"','C');
DBMS_SNAPSHOT.REFRESH( '"CDC"."andanothertable"','C');
DBMS_SNAPSHOT.REFRESH( '"CDC"."lasttable"','C'); 

Open in new window

and have the scheduler run this everyday at 6am

this will refresh them one after another ?
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 39860773
>>this will refresh them one after another ?

Yes.  Stored procedure code is executed sequentially.

I can't speak to the syntax of the DBMS_SNAPSHOT.REFRESH calls you posted.  I would have to defer to the online docs but they look correct assuming you forced case sensitivity on the views by using double quotes.
LVL 74

Expert Comment

ID: 39860793
or put them into a refresh group and refresh the group rather than refreshing each one individually.

That's what refresh groups are for.

Author Comment

ID: 39863794

can you elaborate further on refresh views or point me in the right direction to documentation on what you are speaking of.

I did a search for oracle refresh group and it seems that search is too broad, so not sure where to start.
LVL 74

Accepted Solution

sdstuber earned 250 total points
ID: 39863858

Simple example.  If you have 3 materialized views...


you can put them all in one refresh group with a daily refresh at 6am
with the  MAKE procedure

        name        => 'MY_REFRESH_GROUP',
        list        => 'MY_MV_1, MY_MV_2, MY_MV3',
        next_date   => TRUNC(SYSDATE) + 1 + 6 / 24,
        interval    => 'TRUNC(SYSDATE)+1+6/24'

Or to refresh it manually...


Note, if you already have jobs to refresh them individually, creating the refresh group does not remove those jobs, so your MVs could refresh multiple times.

It's best to pick one or the other scheduling method and then drop the jobs of the other method.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question