ORASOLU TOOLBOX · HIGH AVAILABILITY

Data Guard Status

Practical Oracle Data Guard SQL for reviewing database role, redo transport, apply lag, Data Guard processes, archive gaps and recent events.

ORASOLU TOOLBOX · HIGH AVAILABILITY

Understand the current state of Data Guard

Review the database role, redo transport destinations, apply and transport lag, Data Guard processes, archive gaps and recent Data Guard events.

01 · DATABASE ROLE

Review Data Guard database role

Confirm the database role, protection mode and switchover status for the current Data Guard member.

SELECT
    name,
    db_unique_name,
    database_role,
    open_mode,
    protection_mode,
    protection_level,
    switchover_status
FROM v$database;
02 · REDO DESTINATIONS

Review standby redo destinations

Inspect redo transport destination status and the latest applied SCN reported for standby destinations.

SELECT
    dest_id,
    status,
    type,
    database_mode,
    recovery_mode,
    gap_status,
    applied_scn
FROM v$archive_dest_status
WHERE type = 'PHYSICAL'
ORDER BY dest_id;
03 · APPLY AND TRANSPORT LAG

Review Data Guard lag

Check apply lag and transport lag reported by the standby database.

SELECT
    name,
    value,
    unit,
    time_computed,
    datum_time
FROM v$dataguard_stats
WHERE name IN (
    'apply lag',
    'transport lag',
    'apply finish time'
)
ORDER BY name;
04 · DATA GUARD PROCESSES

Review Data Guard processes

Inspect the current Data Guard processes and their actions to understand transport and apply activity.

SELECT
    role,
    thread#,
    sequence#,
    action,
    client_process,
    client_role
FROM v$dataguard_process
ORDER BY
    role,
    thread#,
    sequence#;
05 · ARCHIVE GAPS

Check for archive gaps

Identify archived redo gaps reported by the standby database that may require investigation.

SELECT
    thread#,
    low_sequence#,
    high_sequence#
FROM v$archive_gap
ORDER BY
    thread#,
    low_sequence#;
06 · DATA GUARD EVENTS

Review recent Data Guard errors

Find recent Error and Fatal Data Guard messages that were recorded by the database.

SELECT
    timestamp,
    severity,
    facility,
    message
FROM v$dataguard_status
WHERE severity IN ('Error', 'Fatal')
  AND timestamp > SYSDATE - 1
ORDER BY timestamp DESC;

ORASOLU TOOLBOX · HIGH AVAILABILITY

Data Guard status should be viewed as a chain.

Start with the database role and redo destination status, then examine transport and apply lag, running Data Guard processes and archive gaps. Recent Data Guard messages can provide additional context when a transport or apply problem is suspected.

Oracle documents V$DATAGUARD_STATS as a source for Data Guard metrics such as apply lag and transport lag. The view returns no rows when queried on a primary database.