• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Identify the Last and Next Refresh Dates for a Materialized View

by admin

A Materialized View refresh synchronizes the MVIEW with it’s master table. In the case of updateable MVIEWs, changes from the MVIEW site are first propagated to master site if the refresh’s push_deferred_rpc parameter is TRUE. Then, changes are pulled from the master site. Pulling rows from master can be either performed using the mview log on the master table (this type of refresh is a FAST refresh), or without using the mview log (this type of refresh is a COMPLETE refresh).

If the refresh is done automatically by a job queue process or by manually executing dbms_job.run(), then finding the next and last refresh times of a refresh can be accomplished by querying dba_jobs as follows:

alter session set nls_date_format='dd-mm-yyyy hh24:mi:ss';

column what format a36
select what, last_date, next_date
from dba_jobs
where upper(what) like 'ÛMS_REFRESH.REFRESH(%%.%%';

WHAT LAST_DATE NEXT_DATE
------------------------------------ ------------------- -------------------
dbms_refresh.refresh('"TESTUSER"."R"'); 10-02-2003 10:48:46 11-02-2003 10:48:46

If the refresh is not performed via dbms_job then the next date can still be determined using the query above. However, the last refresh date will not show the correct date. In this case, last refresh date can be obtained by querying dba_snapshot_refresh_times for each MVIEW of the refresh group.

select rt.owner, rt.name, rt.last_refresh
from dba_refresh_children rc, dba_snapshot_refresh_times rt
where rc.owner=rt.owner and
rc.name =rt.name and
rc.rname='' and
rc.owner='';

OWNER            NAME                           LAST_REFRESH
--------------- ------------------------------ -------------------
TESTUSER         TABLE1                         10-02-2003 10:41:19
TESTUSER         TABLE2                         10-02-2003 10:41:19

Determine if a Specific MVIEW is Being Refreshed

This can be accomplished by examining V$LOCK for any JI type lock acquired on the MVIEW in question.

column owner format a15
column username format a15
column mview format a15
select o.owner, o.object_name mview, username, s.sid
from v$lock l, dba_objects o, v$session s
where o.object_id=l.id1 and
l.type='JI' and
l.lmode=6 and
s.sid=l.sid and
o.object_type='TABLE';


OWNER            MVIEW          USERNAME        SID
--------------- --------------- --------------- ----------
TESTUSER        TABLE1          TESTUSER        16

Filed Under: oracle

Some more articles you might also be interested in …

  1. How to set custom device names using udev in CentOS/RHEL 7
  2. How does the RMAN Retention Policy Obsolete Incremental Backupsets
  3. How to Set Multiple Events in INIT.ORA file
  4. How to Create Undo Tablespace for a Newly Added RAC Instance (ORA-30012)
  5. Oracle SQL Script to Detect Tablespace Fragmentation
  6. RMAN-06059 During RMAN Backup of archivelogs ( How to backup archivelogs moved to a different location)
  7. Oracle Interview Questions : Recovery catalog for RMAN backup
  8. Oracle Database – How to Rename a Datafile with Special Characters Created by Mistake
  9. How to Restore and Recover files over network in Oracle 12c
  10. How to get the DDL for indexes using dbms_metadata

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright