Materialized view refresh every day at 6am.

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,
FutureDBA-Asked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
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
 
slightwv (䄆 Netminder) Commented:
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
 
slightwv (䄆 Netminder) Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
FutureDBA-Author Commented:
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
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
>>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
 
sdstuberCommented:
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
 
FutureDBA-Author Commented:
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
All Courses

From novice to tech pro — start learning today.