fbpx

How to Find Primary Database From Standby in Oracle

If you have an Oracle data guard and you want to know the role of each database then you can follow this guide to get more details about the environment.

You can run these queries in the primary or the standby database indistinctively.

This first query gives a general overview of both primary and standy databases.

set lines 132
column current_scn format 99999999999999999999

select * from v$dataguard_config;

DB_UNIQUE_NAME                 PARENT_DBUN                    DEST_ROLE                   CURRENT_SCN     CON_ID
------------------------------ ------------------------------ ----------------- --------------------- ----------
XT001NFB                       NONE                           PRIMARY DATABASE          4686633244816          0
XT001NSB                       XT001NFB                       PHYSICAL STANDBY          4686633244861          0

If you want to know the role of the database you are connected to:

select name, open_mode, database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
XT001NFB  READ WRITE           PRIMARY

If you want to get even more info, then show this parameter:

show parameter log_archive_config

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_config                   string      dg_config=(XT001NSB,XT001NFB)

If you have data guard broker installed for your data guard (which I recommend), then you can check the configuration like that.

dgmgrl /

DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production

Copyright (c) 2000, 2013, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
Connected as SYSDG.
DGMGRL> show configuration;

Configuration - DG_XT001

  Protection Mode: MaxAvailability
  Members:
  XT001NFB - Primary database
    XT001NSB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 55 seconds ago)

I hope this was helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *