oracle基于时间点的不完全恢复

简介: 下面我们做一个实验,演示如何对oracle进行基于时间点的不完全恢复(在实验之前请确保数据库具有有效备份): 获取此时的时间并记录下来: SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;...
下面我们做一个实验,演示如何对oracle进行基于时间点的不完全恢复(在实验之前请确保数据库具有有效备份):
获取此时的时间并记录下来:
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2014-08-23 00:47:49

把hh用户下的h2删除:
SQL> drop table h2;

Table dropped.

使用rman将数据库恢复到删除h2之前:
关闭数据库,启动rman,重启数据库到mount:
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@localhost ~]$ rman target / nocatalog

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Aug 23 00:55:12 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup mount;

Oracle instance started
database mounted

Total System Global Area     849530880 bytes

Fixed Size                     1339824 bytes
Variable Size                553651792 bytes
Database Buffers             289406976 bytes
Redo Buffers                   5132288 bytes

使用rman将数据库恢复到2014-08-23 00:47:49
RMAN> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';

sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"

RMAN> restore database until time '2014-08-23 00:47:49';

Starting restore at 23-AUG-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

skipping datafile 6; already restored to file /u01/app/datafile/test01.dbf
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/backup/fulldb_0qpgkgjo_1_1
channel ORA_DISK_1: piece handle=/u01/app/backup/fulldb_0qpgkgjo_1_1 tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:06
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/orcl/hh01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/backup/fulldb_0ppgkgjo_1_1
channel ORA_DISK_1: piece handle=/u01/app/backup/fulldb_0ppgkgjo_1_1 tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/backup/fulldb_0opgkgjo_1_1
channel ORA_DISK_1: piece handle=/u01/app/backup/fulldb_0opgkgjo_1_1 tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 23-AUG-14

RMAN> recover database until time '2014-08-23 00:47:49';

Starting recover at 23-AUG-14
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /u01/app/archivelog/dest1/1_1_856304357.dbf
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/archivelog/dest1/1_2_856304357.dbf
archived log for thread 1 with sequence 3 is already on disk as file /u01/app/archivelog/dest1/1_3_856304357.dbf
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/archivelog/dest1/1_1_856310126.dbf
archived log file name=/u01/app/archivelog/dest1/1_1_856304357.dbf thread=1 sequence=1
archived log file name=/u01/app/archivelog/dest1/1_2_856304357.dbf thread=1 sequence=2
archived log file name=/u01/app/archivelog/dest1/1_3_856304357.dbf thread=1 sequence=3
media recovery complete, elapsed time: 00:00:16
Finished recover at 23-AUG-14

使用resetlogs打开数据库:
SQL> alter database open resetlogs;

Database altered.

SQL> select * from hh.h2;


        ID
----------
         1
         2





相关文章
|
存储 SQL Oracle
【历史最全】oracle 获取相应时间 (本周、上周、本月、上月、最近7、30、90天)
在我们使用Oracle数据库的时候,经常会遇到获取相应时间的需求,更甚者,有些涉及写存储过程的兄弟们更是频繁使用到。为了使用起来更加便利,特别留存此记录,便于之后查看。以下SQL均可执行,因为访问的是dual表,所以不需要创建表就能完成调试。
1872 0
|
Oracle 关系型数据库 MySQL
Oracle OCP 19c 考试(1Z0-083)中关于Oracle不完全恢复的考点
下面是Oracle 19c OCP考试(1Z0-083)中关于Oracle不完全恢复的题目:
248 0
|
Oracle 关系型数据库 数据安全/隐私保护
oracle学习25-手工删除oracle归档日志后操作步骤 和修改用户默认解锁时间
oracle学习25-手工删除oracle归档日志后操作步骤 和修改用户默认解锁时间
169 0
|
Oracle 关系型数据库 数据安全/隐私保护
oracle学习22-ora-01691和修改密码过期时间
oracle学习22-ora-01691和修改密码过期时间
161 0
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库
Oracle时间戳与时间互相转换函数
Oracle时间戳与时间互相转换函数
785 0
Oracle时间戳与时间互相转换函数

推荐镜像

更多
下一篇
开通oss服务