If you are using Data Guard and standby databases, you probably need to do stuff based on the database role. For example, have some services start on the primary database, whichever that is. You might want to update some tables upon failover/switchover and more.
There are two mechanisms for that in Oracle databases:
- For services, if you use GI and Data Guard Broker, you can configure services based on the database role. When you create the service using “srvctl”, specify the -l (lowercase L) flag. Available values are PRIMARY, PHYSICAL_STANDBY, LOGICAL_STANDBY and SNAPSHOT_STANDBY.
- For any other case you can configure a database trigger on “AFTER DB_ROLE_CHANGE” event. This trigger will fire when the database is opened for first time after the role change