SQL> select * from v$version ;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> select log_mode,flashback_on,open_mode from v$database;
LOG_MODE FLASHBACK_ON OPEN_MODE
------------ ------------------ ----------
ARCHIVELOG NO READ WRITE
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38759: Database must be mounted by only one instance and not open.
SQL> select * from v$version ;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> select log_mode,flashback_on,open_mode from v$database;
LOG_MODE FLASHBACK_ON OPEN_MODE
------------ ------------------ --------------------
ARCHIVELOG NO READ WRITE
SQL> alter database flashback on;
Database altered.
SQL> select log_mode,flashback_on,open_mode from v$database;
LOG_MODE FLASHBACK_ON OPEN_MODE
------------ ------------------ --------------------
ARCHIVELOG YES READ WRITE
SQL> select * from V$FLASHBACK_DATABASE_LOG;
OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TI RETENTION_TARGET FLASHBACK_SIZE ESTIMATED_FLASHBACK_SIZE
-------------------- ------------------- ---------------- -------------- ------------------------
15807763 2012-08-10 10:19:46 1440 15941632 0
create table t (id number,ins_date date,ins_scn number);
SQL> select 1,sysdate,current_scn from v$database ;
1 SYSDATE CURRENT_SCN
---------- ------------------- -----------
1 2012-08-10 10:26:46 15808025
SQL> insert into t select 1,sysdate,current_scn from v$database ;
1 row created.
SQL> commit ;
Commit complete.
SQL> select sysdate,current_scn from v$database ;
SYSDATE CURRENT_SCN
------------------- -----------
2012-08-10 10:27:06 15808081
SQL> insert into t select 2,sysdate,current_scn from v$database ;
1 row created.
SQL> commit ;
Commit complete.
SQL> select sysdate,current_scn from v$database ;
SYSDATE CURRENT_SCN
------------------- -----------
2012-08-10 10:27:18 15808088
SQL> select * from t;
ID INS_DATE INS_SCN
---------- ------------------- ----------
1 2012-08-10 10:26:57 15808073
2 2012-08-10 10:27:13 15808084
2.测试开始:
SQL> startup mount
ORACLE instance started.
Total System Global Area 2137886720 bytes
Fixed Size 2215064 bytes
Variable Size 1543504744 bytes
Database Buffers 587202560 bytes
Redo Buffers 4964352 bytes
Database mounted.
SQL> flashback database to scn 15808081;
Flashback complete.
SQL> alter database open read only ;
Database altered.
SQL> select * from scott.t;
ID INS_DATE INS_SCN
---------- ------------------- ----------
1 2012-08-10 10:26:57 15808073
SQL> shutdown immediate ;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2137886720 bytes
Fixed Size 2215064 bytes
Variable Size 1543504744 bytes
Database Buffers 587202560 bytes
Redo Buffers 4964352 bytes
Database mounted.
SQL> flashback database to scn 15808088;
Flashback complete.
SQL> alter database open read only ;
Database altered.
SQL> select * from scott.t ;
ID INS_DATE INS_SCN
---------- ------------------- ----------
1 2012-08-10 10:26:57 15808073
2 2012-08-10 10:27:13 15808084
SQL> select database_role,open_mode,flashback_on,current_scn from v$database;
SQL> select database_role,open_mode,flashback_on,current_scn from v$database;
DATABASE_ROLE OPEN_MODE FLASHBACK_ON CURRENT_SCN
---------------- -------------------- ------------------ -----------
PRIMARY READ WRITE YES 15808929
SQL> alter database flashback off;
Database altered.
SQL> select database_role,open_mode,flashback_on,current_scn from v$database;
DATABASE_ROLE OPEN_MODE FLASHBACK_ON CURRENT_SCN
---------------- -------------------- ------------------ -----------
PRIMARY READ WRITE NO 15808981总结:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-740618/ ,如需转载,请注明出处,否则将追究法律责任。