准备工作
这里先建一个数据库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: 表或视图不存在
阅读(2527) | 评论(0) | 转发(0) |