----备份数据文件5
-bash-3.2$ rman target sys/system
backup datafile 5 format '/oracle/rmanbackup/backupwisdomone.dbf';
----恢复数据文件5到新的位置
-bash-3.2$ rman target sys/system
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jun 6 05:04:27 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ZXY (DBID=1701163695)
----注意:run与{在同一行,不然运行会报错
run{
sql 'alter database datafile 5 offline';--恢复数据文件前先离线
set newname for datafile 5 to '/oracle/newwisdomone.dbf';--指定数据文件5新的存储位置
restore datafile 5;--还原数据文件
switch datafile 5;--切换数据文件
recover datafile 5;--恢复数据文件
sql 'alter database datafile 5 online';--数据文件在线
8> }
using target database control file instead of recovery catalog
sql statement: alter database datafile 5 offline
executing command: SET NEWNAME
Starting restore at 06-JUN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
datafile 5 is already restored to file /oracle/newwisdomone.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 06-JUN-13
datafile 5 switched to datafile copy
input datafile copy RECID=3 STAMP=817362275 file name=/oracle/newwisdomone.dbf
Starting recover at 06-JUN-13
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 06-JUN-13
sql statement: alter database datafile 5 online
RMAN> exit
Recovery Manager complete.
-bash-3.2$ sqlplus sys/system as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 6 05:04:46 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
----检查数据文件是否变更为新的存储位置
SQL> select file#,name from v$datafile;
FILE#
----------
NAME
--------------------------------------------------------------------------------
1
/oracle/app/oracle/oradata/zxy/system01.dbf
2
/oracle/app/oracle/oradata/zxy/sysaux01.dbf
3
/oracle/app/oracle/oradata/zxy/undotbs01.dbf
FILE#
----------
NAME
--------------------------------------------------------------------------------
4
/oracle/app/oracle/oradata/zxy/users01.dbf
5
/oracle/newwisdomone.dbf ---这个OK了
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-763202/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-763202/