查询备库的v$archived_log视图。
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APPLIED
---------- ---------
48 YES
49 YES
50 YES
51 YES
52 YES
53 YES
55 YES
54 YES
56 YES
57 YES
58 YES
SEQUENCE# APPLIED
---------- ---------
59 YES
60 YES
61 YES
62 YES
63 YES
64 YES
65 YES
66 YES
19 rows selected.
查询备库v$database视图。
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
查询主库v$databse视图。
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
SQL> alter database commit to switchover to physical standby with session shutdown;
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> alter database commit to switchover to primary with session shutdown;
Database altered.
SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> startup
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size 2253784 bytes
Variable Size 1006636072 bytes
Database Buffers 637534208 bytes
Redo Buffers 7094272 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> set lines 200
SQL> col dest_name for a20
SQL> col error for a20
SQL> select dest_name,status,process,error,transmit_mode from v$archive_dest where target='STANDBY';
DEST_NAME STATUS PROCESS ERROR TRANSMIT_MOD
-------------------- --------- ---------- -------------------- ------------
LOG_ARCHIVE_DEST_2 VALID LGWR ASYNCHRONOUS
SQL> create table Shenyu(id number(10),name varchar2(20));
Table created.
SQL> insert into Shenyu values(1,'Csong');
1 row created.
SQL> insert into Shenyu values(2,'Liyuanyuan');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> desc Shenyu
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(10)
NAME VARCHAR2(20)
SQL> select * from Shenyu;
ID NAME
---------- --------------------
1 Csong
2 Liyuanyuan