ORACLE FLASHBACK DATABASE知识整理(四)

2014-11-24 15:03:36 · 作者: · 浏览: 1
ORACLE instance shut down.
[sql]
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1272213504 bytes
Fixed Size 1336260 bytes
Variable Size 822086716 bytes
Database Buffers 436207616 bytes
Redo Buffers 12582912 bytes
Database mounted.
[sql]
SQL> recover database until cancel;
Media recovery complete.
[sql]
SQL> alter database datafile 7 online;
Database altered.
[sql]
SQL> alter database open resetlogs;
Database altered.
[sql]
SQL> alter tablespace offline_space online;
Tablespace altered.
[sql]
SQL> select * from knight.keyboards;
ID COMPANY TYPE
------------------------------ --------------------
200 SANSUMG MECHINE
201 SNAKE MECHINE
1 IBM 500.55
2 HP 200.5
3 SONY 1200.5
4 ACER 55.6
5 MICROSOFT 108
7 rows selected.
从结果可以看出,新加入的记录被保存了,并没有按照被闪回到指定的时间点,由此说明,闪回数据库时是忽略操作点OFFLINE表空间的。但是此时SCN已经很乱了,必须全备数据库
5.2 闪回点OFFLINE,操作点ONLINE
闪回被很好的执行了,无论是数据还是数据文件的状态都恢复到之前的状态。
1)确定当前时间
[sql]
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2013-07-2720:56:32
2)确定当前SCN
[sql]
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
839748
3)插入knight.keyboards新数据
[sql]
SQL>alter tablespace offline_space online;
Tablespace altered.
4)插入knight.keyboards新数据
[sql]
SQL> insert into knight.keyboards values(200,'SANSUMG','MECHINE');
1 row created.
5)插入knight.keyboards新数据
[sql]
SQL> insert into knight.keyboards values(201,'SNAKE','MECHINE');
1 row created.
[sql]
SQL> commit;
Commit complete.
6) 查看一下表新状态
[sql]
SQL> select * from knight.keyboards;
ID COMPANY TYPE
------------------------------ --------------------
200 SANSUMG MECHINE
201 SNAKE MECHINE
1 IBM 500.55
2 HP 200.5
3 SONY 1200.5
4 ACER 55.6
5 MICROSOFT 108
7)模拟断电关机
[sql]
SQL>shutdown abort;
8)启动到mount模式
[sql]
SQL>startup mount;
9)开始闪回
[sql]
SQL>flashback database to timestamp to_timestamp('2013-07-27 20:56:32','yyyy-MM-dd hh24:mi:ss');
Flashback complete.
10)闪回后各数据文件的状态。
[sql]
SQL> select file#,status from v$datafile;
FILE# STATUS
-----------------
1 SYSTEM
2 RECOVER
3 RECOVER
4 RECOVER
5 RECOVER
6 ONLINE
7 RECOVER
8 RECOVER
8 rows selected.
11)打开前查看一下
[sql]
SQL> alter database open read only;
Database altered.
12)看到此时新加入的数据已经不存在了。
[sql]
SQL> select * from knight.keyboards;
ID COMPANY TYPE
------------------------------ --------------------