查找要恢复到的scn select max(ktuxescnw * power(2, 32) +ktuxescnb) scn from x$ktuxe; 这里是测试用 所以预先可以知道scn,如果是生成系统就得查询日志 ,想办法获得scn了,如查询数据库字典表(V$archived_log or v$log_history),或分析归档与联机日志(logmnr)等。
假如要恢复到的scn是111
先关闭数据库,然后启动到mount下:
shutdown immediate;
startup mount;
run{
allocate channel c1 type disk;
restore database;
recover database until scn 111;
sql 'ALTER DATABASE OPEN RESETLOGS';
release channel c1;
}
RMAN-08055: media recovery complete
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: ALTER DATABASEOPEN RESETLOGS
RMAN-03023: executing command: sql
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: c1
结束。注意:
必须在mount下,restore所有备份数据文件,需要resetlogs.