ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Flashback Database

Flashback Database

原创 Linux操作系统 作者:Jujay 时间:2011-12-15 15:33:39 0 删除 编辑
1. 配置Flashback Database
1)Flashback 功能默认是关闭的:
SQL> select name,flashback_on from v$database;

NAME      FLASHBACK_ON
--------- ------------------
O01DMS0   NO
2)配置Flash recovery area:
SQL> alter system set db_recovery_file_dest_size=2G scope=both;
SQL> alter system set db_recovery_file_dest='H:\flashback' scope=both;
3)启用Flashback Database 功能:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database flashback on;
SQL> select name,flashback_on from v$database;

NAME      FLASHBACK_ON
--------- ------------------
O01DMS0   YES
4)设置db_flashback_retention_target:
SQL> alter system set db_flashback_retention_target=1440 scope=both;
5)打开数据库:
SQL> alter database open;
2. Flashback Database 操作
1)模拟数据丢失:
SQL> create table test as select * from dba_objects;

Table created.

SQL> select count(*) from test;

  COUNT(*)
----------
     10318

SQL> truncate table test;

Table truncated.

SQL> select count(*) from test;

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

2)确认能恢复的时间点
能回退的最早时间,取决于保留的Flashback database log的多少,可以从v$flashback_database_log查看:
SQL> select to_char(OLDEST_FLASHBACK_TIME,'yyyy-mm-dd hh24:mi:ss') from v$flashback_database_log;

TO_CHAR(OLDEST_FLAS
-------------------
2011-12-15 02:41:48

3)恢复数据到指定时间点
SQL> shutdown immediate;
SQL> startup mount;
SQL> flashback database to timestamp to_timestamp('2011-12-15 02:43:00','yyyy-mm-dd hh24:mi:ss');

Flashback complete.

恢复成功后,最好先以readonly的方式打开数据库,以确认恢复达到预期,如果没有达到预期,还可以再进行恢复:
SQL> alter database open read only;

Database altered.

SQL> select count(*) from test;
select count(*) from test
                     *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> shutdown immediate;
SQL> startup mount;
SQL> flashback database to timestamp to_timestamp('2011-12-15 02:49:00','yyyy-mm-dd hh24:mi:ss');

Flashback complete.

SQL> alter database open read only;

Database altered.

SQL> select count(*) from test;

  COUNT(*)
----------
     10318
4)打开数据库
恢复成功后,以resetlog方式打开数据库:
SQL> shutdown immediate;
SQL> startup mount
SQL> alter database open resetlogs;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26277071/viewspace-713387/,如需转载,请注明出处,否则将追究法律责任。

上一篇: Flashback 家族介绍
下一篇: Flashback Drop
请登录后发表评论 登录
全部评论

注册时间:2011-09-14

  • 博文量
    93
  • 访问量
    257725