Materialized view with refresh types in Oracle
Materialized view with refresh types in Oracle :-
The BUILD clause options are shown below.
IMMEDIATE
|
The materialized view is populated immediately.
|
DEFERRED
|
The materialized view is populated on the first requested refresh.
|
The following refresh types are available.
FAST
|
A fast refresh is attempted. If materialized view logs are not present against the source tables in advance, the creation fails.
|
COMPLETE
|
The table segment supporting the materialized view is truncated and repopulated completely using the associated query.
|
FORCE
|
A fast refresh is attempted. If one is not possible a complete refresh is performed.
|
A refresh can be triggered in one of two ways.
ON COMMIT
|
The refresh is triggered by a committed data change in one of the dependent tables.
|
ON DEMAND
|
The refresh is initiated by a manual request or a scheduled task.
|
The following refresh types are available.
--===========MATERIALIZED
VIEW === with refresh types Options
============
The following refresh types are
available.
FAST : A fast refresh is
attempted. If materialized view logs
are not present
against the source tables in
advance, the
creation fails.
COMPLETE : The table segment
supporting the materialized view is
truncated and
repopulated completely using the
associated query.
FORCE : A fast refresh is
attempted. If one is not
possible a complete refresh is
performed.
----- Refresh
Type :- FAST ----
CREATE MATERIALIZED VIEW
XXSD_EMP_M_V1
BUILD IMMEDIATE
REFRESH FAST
ON DEMAND
AS
SELECT * FROM xxsd_emp_tl where
deptno = 10
SELECT * FROM xxsd_emp_tl
desc xxsd_emp_tl
select * from
ALL_CONSTRAINTS
where
TABLE_NAME = 'XXSD_EMP_TL'
alter table xxsd_emp_tl add constraints
XX_EMPNO_PK Primary key (EMPNO)
create materialized view log on XXSD_emp_TL
select * from
XXSD_EMP_M_V1
----- Refresh
Type :- COMPLETE ----
CREATE MATERIALIZED VIEW
XXSD_EMP_M_V2
BUILD IMMEDIATE
REFRESH COMPLETE
ON DEMAND
AS
SELECT * FROM xxsd_emp_tl where
deptno = 10
select * from
XXSD_EMP_M_V2
----- Refresh
Type :- FORCE ----
CREATE MATERIALIZED VIEW
XXSD_EMP_M_V3
BUILD IMMEDIATE
REFRESH FORCE
ON DEMAND
AS
SELECT * FROM xxsd_emp_tl where
deptno = 10
DROP MATERIALIZED VIEW
XXSD_EMP_M_V3
select * from
XXSD_EMP_M_V3
select
object_name,
object_type from
all_objects
where
object_name = 'XXSD_EMP_M_V3'
select * from
ALL_MVIEWS
where
MVIEW_NAME LIKE 'XXSD_EMP_M_V3%'
Comments
Post a Comment