DBAtlas · Database operations atlas

Check primary/standby role and switchover readiness with SQL

OracleData Guard

Command

SELECT name, db_unique_name, database_role, open_mode, protection_mode,
       switchover_status, force_logging, flashback_on, dataguard_broker
FROM   v$database;

-- State of redo destinations and gaps (on the primary):
SELECT dest_id, dest_name, status, type, database_mode,
       recovery_mode, gap_status, error
FROM   v$archive_dest_status
WHERE  status <> 'INACTIVE';

-- Missing archivelog range on the standby:
SELECT thread#, low_sequence#, high_sequence# FROM v$archive_gap;

What it does

Shows the database role, open mode, protection mode, switchover_status (TO STANDBY / TO PRIMARY / SESSIONS ACTIVE / NOT ALLOWED), FORCE LOGGING and flashback state, plus errors and gaps for the redo destinations.

When to use it

As a precheck before switchover/failover, after building a new standby, and for basic monitoring where the broker is not used.

Caution

Read-only. If FORCE_LOGGING=NO, NOLOGGING operations leave corrupt blocks on the standby; ALTER DATABASE FORCE LOGGING must be enabled on a Data Guard primary. If FLASHBACK_ON=NO, the old primary cannot be reinstated after a failover and must be rebuilt.

Open in DBAtlas →

Related