oracle11G闪回flashback(八)
mounted.
SQL> alter database flashback on;--启动数据库闪回
Database altered.
SQL> !ls /u01/app/oracle/flash_recovery_area
jiagulun JIAGULUN
[oracle@localhost flashback]$ pwd
/u01/app/oracle/flash_recovery_area/JIAGULUN/flashback
[oracle@localhost JIAGULUN]$ cd flashback/
[oracle@localhost flashback]$ ls
o1_mf_bd97qnhk_.flb o1_mf_bd987hyb_.flb SQL> alter database open;
Database altered.
SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'
-----------------
20150124 23:47:01
SQL> select name from v$tablespace;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
TESTTS
TEMP2
TEMP3
UNDOTBS2
TEST_TRAN_TS
11 rows selected.
SQL> create tablespace test_flashback_database datafile '/u01/app/oracle/oradata/jiagulun/test_flashback_database.dbf' size 10m;
Tablespace created.
SQL> select name from v$tablespace;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
TESTTS
TEMP2
TEMP3
UNDOTBS2
TEST_TRAN_TS
NAME
------------------------------
TEST_FLASHBACK_DATABASE
12 rows selected.
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
Total System Global Area 400846848 bytes
Fixed Size 2213776 bytes
Variable Size 276826224 bytes
Database Buffers 117440512 bytes
Redo Buffers 4366336 bytes
Database mounted.
SQL> flashback database to timestamp to_date('20150124 23:47:01','yyyymmdd hh24:mi:ss');
Flashback complete.
SQL> startup force
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
Total System Global Area 400846848 bytes
Fixed Size 2213776 bytes
Variable Size 276826224 bytes
Database Buffers 117440512 bytes
Redo Buffers 4366336 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL>
alter database open resetlogs;--为什么会要求open为resetlog? 因为:数据库被闪回了,那么从闪回前在到闪回点的重做日志对于数据库来说已经是无效的了。所以要求重设日志。 SQL> alter database open read only;--有两种模式:read only、read write;之所以为这种状态,因为数据库在闪回后,就不是现在的数据库了
数据库的状态发生了改变,不希望其他用户登录进来防止出现问题
Database altered.
SQL> select name from v$tablespace;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
TESTTS
TEMP2
TEMP3
UNDOTBS2
TEST_TRAN_TS
TEST_FLASHBACK_DATABASE--已经不存在了,被闪回了 11 rows selected.
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
Total System Global Area 400846848 bytes
Fixed Size 2213776 bytes
Variable Size 276826224 bytes
Database Buffers 117440512 bytes
Redo Buffers 4366336 bytes
Database mounted.
SQL> alter database archivelog
2 ;
Database altered.
SQL>
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/archive02/
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL> alter database noarchivelog;--归档变成非归档
alter database noarchivelog
*
ERROR at line 1:
ORA-38774: cannot disable media recovery - flashback database is enabled
-