--primary
select group#,member,type from v$logfile where type='STANDBY';
--standby
show parameter log_archive_dest_2;
----both primary and standby----
select file#, name, status from v$tempfile; --(dba_temp_file)
--select file_name,bytes/1024/1024 "SizeMB",maxbytes/1024/1024 "MaxSize MB",autoextensible from dba_temp_files;

----both primary and standby----
select db_unique_name, status, protection_mode, synchronization_status, synchronized from v$archive_dest_status where dest_id=2;
--primary
select thread#,max(sequence#) from v$archived_log group by thread#;
--standby
select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
select thread#,sequence#,process,status,client_process from v$managed_standby where thread#=1;
select name,value,time_computed from v$dataguard_stats;
SQL>!date ----or select to_char(sysdate, 'MM/DD/YYYY HH24:MI:SS') from dual;

----primary----
select switchover_status from v$database;
alter database commit to switchover to physical standby with session shutdown;
select thread#,sequence#,END_OF_REDO,END_OF_REDO_TYPE from v$archived_log;

----standby----
select switchover_status from v$database;
NOT ALLOWED
SWITCHOVER PENDING
TO PRIMARY


select CURRENT_SCN,STANDBY_BECAME_PRIMARY_SCN from v$database;
select db_unique_name,database_role,open_mode from v$database;
alter database commit to switchover to primary;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

--new primary----?
startup;
select database_role from v$database;
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
——————–
RESOLVABLE GAP

--new standby----
--database idle
--restart new standby windows service
select status from v$instance;
shutdown immediate;
startup nomount;
alter database mount standby database;
select database_role from v$database;
select switchover_status from v$database;
SQL> select switchover_status from v$database;
 SWITCHOVER_STATUS
——————–
RECOVERY NEEDED
