Materialized view refresh

Hi Team,

I need an help in creating an materialzed view which will do a incremental refresh in the week days and full refresh in the weekends

The challenge is I want to how to refresh for the view as the view is created by select * from view name i.e it gets data from the view and base tables.
The below is the implementation
Create or replace viewname
as Select a.col1 ,b. Col2
from tab1 a , tab2 b
where a.col3=b.col4

Create or replace viewname1
as Select a.col3 ,b. Col5,b.col6
from tab1 a , tab2 b
where a.col1=b.col2

Create or replace viewname2
as Select a.col1 ,b. Col5,b.col6
from viewname a , viewname1 b
where a.col1=b.col2

Now the materialized view is created as below

Select * from viewname2;

I want to refresh the view in incremental during weekdays and full refresh on the weekends. Also when Iam trying to refresh the view , should I create the materialized log on the base tables or the views ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnsoneSenior Oracle DBACommented:
I don't believe that you can do a fast refresh of a materialized view based on views.  Maybe you can.  Going from memory though, but I believe that would be considered a complex view which wouldn't be eligible for fast refresh.  You can always try to create it with fast refresh and it will tell you if you can't do that.

What you really should be doing, is simplifying the query in the materialized view.  Your sample queries don't make sense because VIEWNAME2 is using a join on a column that doesn't exist in VIEWNAME1.  Taking a guess, this is what it should look like (assuming that the table names in the views aren't really the same).

SELECT a.col1, 
FROM   tab1 a, 
       tab2 b, 
       tab1 c, 
       tab2 d 
WHERE  a.col3 = b.col4 
       AND c.col1 = d.col2 
       AND a.col1 = d.col2; 

Open in new window

For the refresh schedule you want, I have no idea why you want to do both fast and complete refreshes.  If you really want that, I would suggest creating the view as fast refresh and then scheduling a job to do the completes when you want.  I also don't recall the effect of a complete refresh on the materialized view log, if it doesn't truncate it, then the database will have to process all the records anyway.

You would have to play with the setting of NEXT in the materialized view to get it to refresh only on weekdays.  It's possible.

Any materialized view logs would have to be created on the base tables.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.