Monday 11 November 2019

How to create Materialized Views in Oracle 12

There are two steps to create Materialized Views in 12.2
1.    Create Logical View
2.    Upgrade to Materialized View


Create Logical View
CREATE OR REPLACE VIEW <Custom Schema>.XXXXX_CREATE_CUSTOMER_MV#
AS
<SELECT Statement>;



Upgrade Logical View to Materialized View
exec ad_zd_mview.upgrade('<custom schema>', 'XXXXX_CREATE_CUSTOMER_MV');

How to check if the Materialized Views got created properly in 12.2

SELECT object_type, object_name
FROM dba_objects
WHERE object_name like 'XXXXX_CREATE_CUSTOMER_MV%';


-- 4 rows Selected

These 4 Rows get created in the process for
  1. Logical View (Ending with '#') in Custom Schema
  2. Materialized View in Custom Schema
  3. Table in Custom Schema
  4. Synonym in APPS



How to Refresh Materialized Views:


exec DBMS_MVIEW.REFRESH('XXXXX_CREATE_CUSTOMER_MV', method => '?',  atomic_refresh => FALSE, out_of_place => TRUE);

Parameters in detail:
Refresh Method
Parameter
Description
COMPLETE
C
Refreshes by recalculating the defining query of the materialized view.
FAST
F
Refreshes by incrementally applying changes to the materialized view.
For local materialized views, it chooses the refresh method which is estimated by optimizer to be most efficient. The refresh methods considered are log-based FAST and FAST_PCT.
FAST_PCT
P
Refreshes by recomputing the rows in the materialized view affected by changed partitions in the detail tables.
FORCE
?
Attempts a fast refresh. If that is not possible, it does a complete refresh.
For local materialized views, it chooses the refresh method which is estimated by optimizer to be most efficient. The refresh methods considered are log based FAST, FAST_PCT, and COMPLETE.



No comments:

Post a Comment