大量数据文件恢复时,set new…
2017-05-02 11:01
281 查看
需要把大量数据文件恢复到新的目录(如RMAN异机恢复),可以设置DB_CREATE_FILE_DEST参数,使用OMF自动生成文数据文件名,比拼SQL还要简单快速
set newname for datafile * to NEW;
参考文档:
Goal
Solution
--------------------------------------------------------------------------------
Applies to:
Oracle Database - Standard Edition - Version 10.1.0.2 and
later
Oracle Database - Enterprise Edition - Version 9.0.1.2 and
later
Information in this document applies to any platform.
***Checked for relevance on 29-Apr-2013***
Goal
When you must restore the database the same directory structure is
not always there. If you have a database containing 1000s of
datafiles it can be very tedious to setup the set newname commands
for all the datafiles.
Using sqlplus we can extract the information we need into a file
which can then be easily modifed and executed as an RMAN script to
complete the task.
Solution
You are restoring or duplicating the target database to a new host
using RMAN. The datafiles are not OMF files and you want to make
them OMF. Using 'set newname for datafile to NEW' will generate a
new OMF filename for the restored datafile.
This will avoid the manual entry or vi/notepad editing of similar
output. Using this output the datafiles will be restored to the
DB_CREATE_FILE_DEST. If this parameter is not set you must add the
correct path as in '/path/NEW' will direct the files to the new
location and give an OMF filename.
sqlplus /nolog
connect system/manager
set echo off pages 0 feed off sqlp #
spool /path/setnewnamedf.lst
select 'set newname for datafile '||file#||' to NEW;' from
v$datafile;
-- select 'set newname for datafile '||file#||' to /newpath/NEW;'
from v$datafile;
spool offThere are 2 select statements above with slightly
different output.
Select #1 Output:
set newname for datafile 1 to NEW;
set newname for datafile 2 to NEW;
set newname for datafile 3 to NEW;
set newname for datafile 4 to NEW;
set newname for datafile 5 to NEW;
Select #2 Output:
set newname for datafile 1 to /newpath/NEW;
set newname for datafile 2 to /newpath/NEW;
set newname for datafile 3 to /newpath/NEW;
set newname for datafile 4 to /newpath/NEW;
set newname for datafile 5 to /newpath/NEW;
In this scenario you do not use OMF naming for your files and you
want to continue to control the datafile names. To generate set
newname commands to point to an ASM volume execute the sql below.
It will create a file that you just add your restore command to
complete the script and execute in RMAN inside a run
block.
sqlplus /nolog
connect system/manager
set echo off pages 0 feed off sqlp #
spool /path/setnewnamedf.lst
select 'set newname for datafile '||file#||' to ''+DG'';' from
v$datafile;
spool offSelect #3 Output:
set newname for datafile 1 to '+DG';
set newname for datafile 2 to '+DG';
set newname for datafile 3 to '+DG';
set newname for datafile 4 to '+DG';
set newname for datafile 5 to '+DG';
With the following query you keep the same path and name as on the
original target. Using vi global search and replace you change
change the path to the new directory using %s. This becomes very
useful when there are
a46d
1000s of files to update. If using multiple
directories you can split the output to change the path all in a
file then merge the files or find a quicker method. Here is the
example output of before and after the search and
replace.
set echo off pages 0 feed off sqlp #
spool setnewnamedf.lst
select 'set newname for datafile '||file#||' to '''||name||''';'
from v$datafile;
spool offSelect #4 Output: Before change:
set newname for datafile 1 to
'/u01/64bit/app/oracle/oradata/V102REP1/system01.dbf';
set newname for datafile 2 to
'/u01/64bit/app/oracle/oradata/V102REP1/undotbs01.dbf';
set newname for datafile 3 to
'/u01/64bit/app/oracle/oradata/V102REP1/sysaux01.dbf';
set newname for datafile 4 to
'/u01/64bit/app/oracle/oradata/V102REP1/users01.dbf';
set newname for datafile 5 to
'/u01/64bit/app/oracle/oradata/V102REP1/fujitsu_1.dbf';
Command to change the above path:
:%s/\/dir1\/dir2/\/newdir1\/newdir2/g
:%s/\/u01\/64bit\/app\/oracle\/oradata\/V102REP1/\/newpath/gAfter
executing the search and replace we are left with:
set newname for datafile 1 to '/newpath/system01.dbf';
set newname for datafile 2 to '/newpath/undotbs01.dbf';
set newname for datafile 3 to '/newpath/sysaux01.dbf';
set newname for datafile 4 to '/newpath/users01.dbf';
set newname for datafile 5 to '/newpath/fujitsu_1.dbf';
Using these methods, or something similar with other editors,
you can quickly setup a restore or duplicate script to be used on a
new host and directory structure no matter the number of files.
--------------------------------------------------------------------------------
set newname for datafile * to NEW;
参考文档:
Goal
Solution
--------------------------------------------------------------------------------
Applies to:
Oracle Database - Standard Edition - Version 10.1.0.2 and
later
Oracle Database - Enterprise Edition - Version 9.0.1.2 and
later
Information in this document applies to any platform.
***Checked for relevance on 29-Apr-2013***
Goal
When you must restore the database the same directory structure is
not always there. If you have a database containing 1000s of
datafiles it can be very tedious to setup the set newname commands
for all the datafiles.
Using sqlplus we can extract the information we need into a file
which can then be easily modifed and executed as an RMAN script to
complete the task.
Solution
You are restoring or duplicating the target database to a new host
using RMAN. The datafiles are not OMF files and you want to make
them OMF. Using 'set newname for datafile to NEW' will generate a
new OMF filename for the restored datafile.
This will avoid the manual entry or vi/notepad editing of similar
output. Using this output the datafiles will be restored to the
DB_CREATE_FILE_DEST. If this parameter is not set you must add the
correct path as in '/path/NEW' will direct the files to the new
location and give an OMF filename.
sqlplus /nolog
connect system/manager
set echo off pages 0 feed off sqlp #
spool /path/setnewnamedf.lst
select 'set newname for datafile '||file#||' to NEW;' from
v$datafile;
-- select 'set newname for datafile '||file#||' to /newpath/NEW;'
from v$datafile;
spool offThere are 2 select statements above with slightly
different output.
Select #1 Output:
set newname for datafile 1 to NEW;
set newname for datafile 2 to NEW;
set newname for datafile 3 to NEW;
set newname for datafile 4 to NEW;
set newname for datafile 5 to NEW;
Select #2 Output:
set newname for datafile 1 to /newpath/NEW;
set newname for datafile 2 to /newpath/NEW;
set newname for datafile 3 to /newpath/NEW;
set newname for datafile 4 to /newpath/NEW;
set newname for datafile 5 to /newpath/NEW;
In this scenario you do not use OMF naming for your files and you
want to continue to control the datafile names. To generate set
newname commands to point to an ASM volume execute the sql below.
It will create a file that you just add your restore command to
complete the script and execute in RMAN inside a run
block.
sqlplus /nolog
connect system/manager
set echo off pages 0 feed off sqlp #
spool /path/setnewnamedf.lst
select 'set newname for datafile '||file#||' to ''+DG'';' from
v$datafile;
spool offSelect #3 Output:
set newname for datafile 1 to '+DG';
set newname for datafile 2 to '+DG';
set newname for datafile 3 to '+DG';
set newname for datafile 4 to '+DG';
set newname for datafile 5 to '+DG';
With the following query you keep the same path and name as on the
original target. Using vi global search and replace you change
change the path to the new directory using %s. This becomes very
useful when there are
a46d
1000s of files to update. If using multiple
directories you can split the output to change the path all in a
file then merge the files or find a quicker method. Here is the
example output of before and after the search and
replace.
set echo off pages 0 feed off sqlp #
spool setnewnamedf.lst
select 'set newname for datafile '||file#||' to '''||name||''';'
from v$datafile;
spool offSelect #4 Output: Before change:
set newname for datafile 1 to
'/u01/64bit/app/oracle/oradata/V102REP1/system01.dbf';
set newname for datafile 2 to
'/u01/64bit/app/oracle/oradata/V102REP1/undotbs01.dbf';
set newname for datafile 3 to
'/u01/64bit/app/oracle/oradata/V102REP1/sysaux01.dbf';
set newname for datafile 4 to
'/u01/64bit/app/oracle/oradata/V102REP1/users01.dbf';
set newname for datafile 5 to
'/u01/64bit/app/oracle/oradata/V102REP1/fujitsu_1.dbf';
Command to change the above path:
:%s/\/dir1\/dir2/\/newdir1\/newdir2/g
:%s/\/u01\/64bit\/app\/oracle\/oradata\/V102REP1/\/newpath/gAfter
executing the search and replace we are left with:
set newname for datafile 1 to '/newpath/system01.dbf';
set newname for datafile 2 to '/newpath/undotbs01.dbf';
set newname for datafile 3 to '/newpath/sysaux01.dbf';
set newname for datafile 4 to '/newpath/users01.dbf';
set newname for datafile 5 to '/newpath/fujitsu_1.dbf';
Using these methods, or something similar with other editors,
you can quickly setup a restore or duplicate script to be used on a
new host and directory structure no matter the number of files.
--------------------------------------------------------------------------------
相关文章推荐
- RMAN 恢复实际操作(模拟数据文件…
- 恢复Set unused的字段数据
- MAN 恢复实际操作(模拟数据文件丢…
- 恢复删除的数据文件案例《from&nbs…
- ORACLE 11G 数据文件头格式
- 【转&参考】MySQL利用frm和ibd文件进行数据恢复
- SQL Server 2005移动数据文件
- ios 将数据写入到文件
- 对某网站LINUX FSCK后丢失大量文件的数据恢复过程摘录
- SYBASE ASE数据误删除之后的恢复处…
- oracle11g 数据文件误删恢复(…
- 通过cat 数据文件来合并 myisam表
- SQL SERVER 2005恢复数据错误解决:The backup set holds a backup of a database other than the existing 'XXX' database
- MYSQL 备份恢复数据
- sqlldr加载 数据文件的字段超出最…
- SQL大量数据查询的优化 及 非用lik…
- RMAN - "丢失控制文件的恢复"
- ORA-01190: 控制文件或数据文件 1 …
- MySQL ibdata损坏或丢失 通过frm&ibd文件恢复数据
- Oracle 重命名数据文件