ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
Error occurred due to Switchover having active session
I am trying to switchover the primary database to standby database then i am getting the following error:
SQL> alter database commit to switchover to physical standby; alter database commit to switchover to physical standby * ERROR at line 1: ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
Solution:
For disconnect the active user you can use the clause WITH SESSION SHUTDOWN.
-- From primary if getting error:
PRIM> alter database commit to switchover to physical standby with session shutdown;
-- From Standby if getting error:
Standby> alter database commit to switchover to primary with session shutdown;
Note:
You can verify before switch over command with switchover_status column in v$database.
It tell you that any session is active at time of switchover or not.
Following value means session is active. use this command at both primary or Standby before switch over.
SQL> select switchover_status from v$database;SWITCHOVER_STATUS -------------------- SESSIONS ACTIVE
Value of Switchover at primary and Standby as follow then it good to go for switchover the Dataguard environment.
STANDBY> select switchover_status from v$database;SWITCHOVER_STATUS -------------------- TO PRIMARY PRIM> select switchover_status from v$database; SWITCHOVER_STATUS -------------------- TO STANDBY