# How To Check DataGuard Status

Oracle Database - 11.2

Show the last archive produced in primary and the last archive applied to standby.

SET linesize 200 pagesize 100
SELECT a.thread#, b.last_seq prmy_last_file, a.applied_seq stdby_last_file,
       CASE WHEN b.last_seq - a.applied_seq > 2 THEN '=>' ELSE to_char(b.last_seq - a.applied_seq) END archive_difference,
       TO_CHAR (a.latest_apply_time, 'dd/mm/yyyy hh24:mi:ss') stdby_latest_time
  FROM (SELECT resetlogs_id, thread#, MAX(sequence#) applied_seq, MAX(next_time) latest_apply_time
          FROM v$archived_log
         WHERE applied = 'YES'
      GROUP BY resetlogs_id, thread#) a,
       (SELECT resetlogs_id, thread#, MAX(sequence#) last_seq
          FROM v$archived_log
      GROUP BY resetlogs_id, thread#) b
  WHERE a.thread# = b.thread#
  ORDER BY a.thread#;
SELECT MAX(sequence#),thread#,registrar,applied FROM v$archived_log GROUP BY thread#,registrar,applied;

Display messages recently written to the alert log or server process trace files.

COLUMN message FORMAT a80
SELECT timestamp,facility,message FROM v$dataguard_status ORDER BY timestamp;

Display the archive destination current value, mode, and status.

SELECT status,error,destination FROM v$archive_dest WHERE status NOT IN 'INACTIVE';
Edited on