您的位置:首页 > 数据库

20.4 使用FLASHBACK DATABASE 恢复数据库到先前状态

2009-02-19 23:57 573 查看
FLASHBACK DATABASE 不能用于恢复介绍失败,并且使用 FLASHBACK DATABASE 具有以下限制:

数据库必须处于 ARCHIVELOG 模式 必须激活数据库的 FLASHBACK 特征 必须合理配置初始化参数 db_flashback_retention_target,该初始化参数用于控制可以恢复到的最早时间点
(1) 配置数据库支持

(2) 模拟用户误操作

(3) 确定 FLASHBACK DATABASE 可以恢复到的最早 SCN 值或时间

(4) 使用 FLASHBACK DATABASE 命令恢复数据库到先前状态

SQL*PLUS 中使用 FLASHBACK DATABASE 命令:

SQL> conn / as sysdba
已连接。
SQL> select current_scn from v$database; CURRENT_SCN
-----------
660880 SQL> drop table scott.emp; 表已删除。 SQL> select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log; OLDEST_FLASHBACK_SCN OLDEST_FLASHBA
-------------------- --------------
659643 19-2月 -09 SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。 Total System Global Area 209715200 bytes
Fixed Size 1248116 bytes
Variable Size 71304332 bytes
Database Buffers 130023424 bytes
Redo Buffers 7139328 bytes
数据库装载完毕。
SQL> flashback database to scn 660880; 闪回完成。 SQL> alter database open resetlogs; 数据库已更改。 SQL> select count(*) from scott.emp; COUNT(*)
----------
14

RMAN 中使用 FLASHBACK DATABASE 命令:

C:\>set nls_date_format=yyyy-mm-dd hh24:mi:ss C:\>sqlplus sys/orcl@demo as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 2月 19 23:50:47 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. 连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options SQL> host date
当前日期: 2009-02-19 星期四
输入新日期: (年月日) SQL> host time
当前时间: 23:51:11.81
输入新时间: SQL> drop table scott.emp; 表已删除。 SQL> select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log; OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TI
-------------------- -------------------
659643 2009-02-19 23:24:56 SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开 C:\>rman target sys/oracle@demo nocatalog 恢复管理器: Release 10.2.0.1.0 - Production on 星期四 2月 19 23:52:02 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. 连接到目标数据库: DEMO (DBID=3422263240)
使用目标数据库控制文件替代恢复目录 RMAN> shutdown immediate 数据库已关闭
数据库已卸载
Oracle 实例已关闭 RMAN> startup mount 已连接到目标数据库 (未启动)
Oracle 实例已启动
数据库已装载 系统全局区域总计 209715200 字节 Fixed Size 1248116 字节
Variable Size 71304332 字节
Database Buffers 130023424 字节
Redo Buffers 7139328 字节 RMAN> flashback database to time '2009-02-19 23:51:11'; 启动 flashback 于 2009-02-19 23:53:26
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=155 devtype=DISK 正在开始介质的恢复
介质恢复完成, 用时: 00:00:15 完成 flashback 于 2009-02-19 23:53:44 RMAN> alter database open resetlogs; 数据库已打开 RMAN> run {host 'sqlplus scott/tiger@demo';} SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 2月 19 23:54:37 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. 连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options SQL> select count(1) from emp; COUNT(1)
----------
14
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: