Oracle: Fast Refresh Materialized View with Joins

Step 1: Create Materialized View Log with Rowid on Each Table
create materialized view log on emp with rowid;
create materialized view log on dept with rowid;

Step 2: Create Materialized View with rowids for all the base tables

create materialized view empdept_mv
refresh fast on commit as
    e.rowid e_rowid,
    d.rowid d_rowid,
    emp e,
    dept d
    e.deptno = d.deptno;



NOTE: Restrictions on Fast Refresh on Materialized Views with Joins Only
-    All restrictions from "General Restrictions on Fast Refresh".
-    They cannot have GROUP BY clauses or aggregates.
-    Rowids of all the tables in the FROM list must appear in the SELECT list of the query.
-    Materialized view logs must exist with rowids for all the base tables in the FROM list of the query.
-    You cannot create a fast refreshable materialized view from multiple tables with simple joins that include an object type column in the SELECT statement.


  1. Hi all! can anyone explain me why are we using build immediate in materialized views.?? And also why do we use REFRESH FORCE ON DEMAND when we have dbms_mview.refresh??

    1. there are 2 options to build a mview build immediate & build deferred. The materialized view does not initially contain any data if build method is DEFERRED. A complete refresh is required for the first refresh of a build deferred materialized view.

    2. REFRESH FORCE ON DEMAND is ofcoure on demand refresh, REFRESH FORCE to take advantage of fast refresh when it is possible. This needs to be refreshed manually using dbms_mview.refresh or dbms_refresh.refresh.

  2. Hi Nimish ;

    May i know the difference between Master table Vs Local Base table. I am getting confused. Where to get all basic table information when creating materialized view?

    1. I think both Master table and Base table are same. Just different words to use same item.

  3. Thanks buddy. This post was really helpful

  4. Hi Nimish ,

    There is one question asked in the interview ?

    we have created materialized view with fast refresh by joining multiple table ( say 3 tables). The Question is every 5 sec DML operation is done on Base tables( i.e. 3 tables) and frequency of materialized view refresh is 10 sec. This materialized is used by GUI.
    there is delay of 5sec. So what is the best approach you will suggest to see all data without 5 sec delay?

  5. Hi all,

    Could you please clarify me that does we can create fast refresh materialized view when we are using user defined function in our select clause.