* A closer look at a simple fast refresh
Here is what ORACLE is doing behind the scene during a fast refresh...
SQL>
SQL> select * from t2_a;
C1 C2
-- ----------
a 1
b 2
SQL> alter table t2_a add constraint t2_a_pk primary key (c1);
Table altered.
SQL>
SQL> create materialized view log on t2_a
2 with primary key
3 including new values;
Materialized view log created.
SQL>
SQL> create materialized view t2_a_mv as select * from t2_a;
Materialized view created.
SQL>
SQL> -- 1 row added to MV log
SQL> insert into t2_a values('c',3);
1 row created.
SQL> select * from mlog$_t2_a;
C1 SNAPTIME$$ DMLTYPE$$ OLD_NEW$$ CHANGE_VECTOR$$
-- -------------------- ---------- ---------- ----------------
c 010100 00:00:00 I N FE
SQL>
SQL> -- 2 rows added to MV log
SQL> update t2_a set c2=0 where c1='c';
1 row updated.
SQL> select * from mlog$_t2_a;
C1 SNAPTIME$$ DMLTYPE$$ OLD_NEW$$ CHANGE_VECTOR$$
-- -------------------- ---------- ---------- ----------------
c 010100 00:00:00 I N FE
c 010100 00:00:00 U U 04
c 010100 00:00:00 U N 04
SQL>
SQL> -- 1 row added to MV log
SQL> delete from t2_a where c1='c';
1 row deleted.
SQL> select * from mlog$_t2_a;
C1 SNAPTIME$$ DMLTYPE$$ OLD_NEW$$ CHANGE_VECTOR$$
-- -------------------- ---------- ---------- ----------------
c 010100 00:00:00 I N FE
c 010100 00:00:00 U U 04
c 010100 00:00:00 U N 04
c 010100 00:00:00 D O 00
SQL>
SQL> alter session set sql_trace=true;
Session altered.
SQL> exec dbms_mview.refresh('T2_A_MV','f');
PL/SQL procedure successfully completed.
SQL> alter session set sql_trace=false;
Session altered.
SQL>
SQL> spool off