?
Solved

Materialized view refresh every day at 6am.

Posted on 2014-02-14
7
Medium Priority
?
5,991 Views
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.

Second.

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?

Thanks,
0
Comment
Question by:FutureDBA-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39860753
First:

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
as
select * from sometable

Open in new window


Second:
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.
0
 
LVL 77

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.
0
 

Author Comment

by:FutureDBA-
ID: 39860768
So Can i create this procedure

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

Open in new window


and have the scheduler run this everyday at 6am

this will refresh them one after another ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 1000 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.
0
 
LVL 74

Expert Comment

by:sdstuber
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.
0
 

Author Comment

by:FutureDBA-
ID: 39863794
sdstuber,

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.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 1000 total points
ID: 39863858
http://docs.oracle.com/cd/E11882_01/server.112/e10707/rarrefreshpac.htm#REPMA018

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

MY_MV_1
MY_MV_2
MY_MV_3

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

BEGIN
    DBMS_REFRESH.make(
        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'
    );
END;
/


Or to refresh it manually...

BEGIN
    DBMS_REFRESH.refresh('MY_REFRESH_GROUP');
END;


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.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

765 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