Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5600872
  • 博文数量: 745
  • 博客积分: 10075
  • 博客等级: 上将
  • 技术积分: 7716
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-29 12:09
文章分类

全部博文(745)

文章存档

2019年(1)

2016年(1)

2010年(31)

2009年(88)

2008年(129)

2007年(155)

2006年(197)

2005年(143)

分类: Oracle

2007-12-03 19:26:03

准备工作
这里先建一个数据库rman(用来存放catalog)
创建表空间
SQL> create tablespace rman_ts datafile          
  2  'D:\oracle\oradata\rman\rman_ts.dbf' size 20m
  3   autoextend on next 1m maxsize unlimited    
  4  extent management local uniform size 128k;  
创建用户
SQL> create user rman_owner identified by rman_owner    
  2  default tablespace rman_ts                             
  3  quota unlimited on rman_ts;                            
       
授权
 grant connect,resource,recovery_catalog_owner to rman_owner;

登陆ora9i数据库和恢复目录数据库(rman)
D:\>rman catalog target
创建恢复目录
RMAN> create catalog tablespace rman_ts
注册在恢复目录中的数据库
RMAN> register database;
给数据库做一个备份
注意:可能需要切换副本
RMAN> list incarnation of database;

数据库 Incarnations 列表
DB 关键字  Inc 关键字 DB 名  DB ID            CUR 重置 SCN   重置时间
------- ------- -------- ---------------- --- ---------- ----------
1       13      UNKNOWN   2439988007       NO  240781     2007-12-03:16:27:21
1       2       ORA9I     2439988007       YES 305031     2007-12-03:18:44:02
RMAN>  reset database to incarnation 2;
SQL> create table scott.test2(n1 number) tablespace users;
SQL> insert into scott.test2 values(1);
SQL> insert into scott.test2 values(2);
SQL> alter system switch logfile;
 
SQL> drop tablespace users including contents and datafiles;
SQL>  create table scott.test3(n1 number) tablespace tools;
SQL> insert into scott.test3 values(2);
SQL> shutdown abort
在 ora9iALRT.log里
Mon Dec 03 19:16:23 2007
Deleted file D:\ORACLE\ORADATA\ORA9I\USERS01.DBF
Completed: drop tablespace users including contents and dataf

恢复到2007-12-03:19:16:22的样子
RMAN> startup nomount
RMAN>
 run {                           
 set until time='2007-12-03:19:16:22';                                  
 restore controlfile;               
 alter database mount;              
 restore database;                  
 recover database;                  
 alter database open resetlogs;}  
恢复完之后
 
SQL> select * from scott.test2;                      
                             
        N1                   
----------                   
         1                   

SQL> select * from scott.test3;
select * from scott.test3
                    *
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在    
阅读(2489) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~