Materialized View
Materialized View
Materialized view is a data base object that stores query result or precomputed
result.
When we see the performance of Materialized view it is better than normal View
because the
data of materialized view will stored in table and table may be indexed so faster.
1. Normal
2. Pre-Built
Refreshing Types:
----------------
1. Complete
2. Fast - Primary Key Must in the Based table for the creation of MV.
3. Force
Complete Refresh :
-----------------
Complete Refresh -> It will Trunc the Data stored on the materialized view and
then load the fresh
data to the materialized based on the select query in
materialized view.
Example:
-------
CREATE MATERIALIZED VIEW MV1
BUILD IMMEDIATE
REFRESH COMPLETE
START WITH SYSDATE
NEXT SYSDATE+3/1440
AS
SELECT * FROM products;
Fast Refresh :
------------
Primary Key Must in the Based table for the creation of MV.
In Fast Refresh Materialized View Log Must for all table as per the select
statement in MV otherwise throw error.
Primary Key Must in the base table to the materialized view log
Example:
--------
FAST REFRESH:
------------
In Complete Refresh Method give the first preference to the Fast Refresh at the
time
Materialized view log Found. Else it will automatically proceed the complete
refresh method.
Example :
-------
Refresh Events :
--------------
1. On Demand -> Is the Manual Refresh Method (DBMC_MVIEW.REFRESH)
2. On Commit -> Refresh action will take place on the time of On Commit.
In this case, you can convert an existing table to a materialized view by using
the ON PREBUILT
TABLE clause.
Example :
--------