----Primary----
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO STANDBY

----Primary----
SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.

----Primary----
check alertlog shows switchover
D:\app\oracle\diag\rdbms\PC_PROD\PC_PROD\trace

----primary  EOR----
SQL> select thread#,sequence#,END_OF_REDO,END_OF_REDO_TYPE from v$archived_log;
THREAD# SEQUENCE# END END_OF_RED
---------- ---------- --- ----------
1 337 NO
1 337 NO
1 338 YES SWITCHOVER

(---- old primary, now standby ----
shutdown abort;
startup mount;
)

----Standby monitoring----
--During switchover command execution on the primary database, if you monitor the switchover status of the standby database closely, you can capture it as shown in the following code:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
NOT ALLOWED
SQL> /
SWITCHOVER_STATUS
--------------------
SWITCHOVER PENDING
SQL> /
SWITCHOVER_STATUS
--------------------
TO PRIMARY
--once "TO PRIMARY or SESSIONS ACTIVE", the old standby is ready to switch to primary


----standby----
--Perform switchover from the standby database. By default the switchover status of the standby database will be "NOT ALLOWED". After processing switchover from
--the primary database, during recovery the status will be changed to SWITCHOVER PENDING. Once End-of-Redo is applied on standby, the database will be ready to become primary as shown in the following code:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY

----Standby----
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.

----Standby----
check alertlog
D:\app\oracle\diag\rdbms\SC_PROD\SC_PROD\trace

----new primary (PC_PRODDR)----
SQL> select CURRENT_SCN,STANDBY_BECAME_PRIMARY_SCN from v$database;
CURRENT_SCN STANDBY_BECAME_PRIMARY_SCN
----------- --------------------------
3156173 3085367

----new primary (PC_PRODDR)----
----Change the open mode of the new primary to READ-WRITE. 
----After successful switchover from standby to the primary database, the instance status will be "MOUNTED" as shown in the following code:
SQL> select db_unique_name,database_role,open_mode from
v$database;
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE
-------------------- ---------------- --------------------
UC1_SC_PROD PRIMARY MOUNTED

----Open the database with the following statement:
SQL> alter database open;
Database altered.

****( ---- could be done after primary switchover ----
----new standby (PC_PROD)----
----Restart the new standby database and start Redo Apply. 
----After switchover, the new standby instance will be in the "NOMOUNT" status.
SQL> select status from v$instance;
STATUS
------------
STARTED

----new standby (PC_PROD)----
SQL> select db_unique_name,database_role,open_mode from v$database;
--should be in the "NOMOUNT" status.

----new standby (PC_PROD)----
SHUTDOWN IMMEDIATE;
startup mount;

----new standby (PC_PROD)----
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.

----new standby (PC_PROD)----
SQL> select db_unique_name,open_mode from v$database;
DB_UNIQUE_NAME OPEN_MODE
--------------- --------------------
VA1_PC_PROD MOUNTED
)****

----Note: Active Data Guard----
----Now perform a clean shutdown with SHUTDOWN IMMEDIATE and then start up the new standby database (in the READ ONLY mode if Active Data Guard will be used). Then start Redo Apply on the standby database (VA1_PC_PROD)
shut immediate;
startup mount;
alter database open read only;

----new standby (PC_PROD)----
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select db_unique_name,open_mode from v$database;
DB_UNIQUE_NAME OPEN_MODE
--------------- --------------------
VA1_PC_PROD_un READ ONLY WITH APPLY

----If you have multiple standby databases in the Data Guard configuration, start Redo Apply on each standby database.

