oracle闪回数据库详解(二)

2014-11-24 09:09:01 · 作者: · 浏览: 1

YES


SYS@ORCL>

实验2:闪回数据库用途 -----实验参考eygle 的循序渐进oracle

SYS@ORCL>conn tyger/tyger
Connected.
TYGER@ORCL>select count(*) from tyger;


COUNT(*)
----------
1


TYGER@ORCL>select count(*) from test;


COUNT(*)
----------
14


TYGER@ORCL>alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss';


Session altered.


TYGER@ORCL>select sysdate from dual;


SYSDATE
-------------------
2014-03-11 15:47:14


TYGER@ORCL>truncate table tyger;


Table truncated.


TYGER@ORCL>select sysdate from dual;


SYSDATE
-------------------
2014-03-11 15:47:38


TYGER@ORCL>truncate table test;


Table truncated.


TYGER@ORCL>select sysdate from dual;


SYSDATE
-------------------
2014-03-11 15:48:03

闪回需要在Mount状态下进行,可以指定Timestamp/SCN/Sequence进行闪回。

首先将数据库闪回到第一时间点,以Redo only的方式打开数据库:

SYS@ORCL>startup mount;
ORACLE instance started.


Total System Global Area 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 130024872 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
Database mounted.
SYS@ORCL>flashback database to timestamp
2 to_timestamp('2014-03-11 15:47:14','yyyy-mm-dd hh24:mi:ss');


Flashback complete.


SYS@ORCL>alter database open read only; //以read only原因:如果数据恢复的不够理想,可以关闭数据库继续进行恢复


Database altered.


SYS@ORCL>select count(*) from tyger.tyger;


COUNT(*)
----------
1


SYS@ORCL>select count(*) from tyger.test;


COUNT(*)
----------
14

数据恢复不理想,继续进行恢复 ---前提:以redo only打开数据库

SYS@ORCL>startup mount;
ORACLE instance started.


Total System Global Area 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 130024872 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
Database mounted.
SYS@ORCL>flashback database to timestamp
2 to_timestamp('2014-03-11 15:47:38','yyyy-mm-dd hh24:mi:ss');


Flashback complete.


SYS@ORCL>alter database open read only;


Database altered.


SYS@ORCL>select count(*) from tyger.tyger;


COUNT(*)
----------
0


SYS@ORCL>select count(*) from tyger.test;


COUNT(*)
----------
14

如果数据恢复确认完成,就可以以resetlogs打开数据库,恢复工作 ------重置日志,不能再flashback至resetlogs之前的时间点

SYS@ORCL>alter database open resetlogs;


Database altered.

oracle闪回表详解:http://blog.csdn.net/wanghui5767260/article/details/21084031