Database Reference
In-Depth Information
This example changes the location of data files when doing a restore and recover. First, place the database in
mount mode:
$ rman target /
RMAN> startup mount;
Then, run the following block of RMAN code:
run{
set newname for datafile 4 to '/u02/dbfile/O12C/users01.dbf';
set newname for datafile 5 to '/u02/dbfile/O12C/users02.dbf';
restore datafile 4, 5;
switch datafile all; # Updates repository with new datafile location.
recover datafile 4, 5;
alter database open;
}
This is a partial listing of the output:
datafile 4 switched to datafile copy
input datafile copy RECID=79 STAMP=804533148 file name=/u02/dbfile/O12C/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=80 STAMP=804533148 file name=/u02/dbfile/O12C/users02.dbf
If the database is open, you can place the data files offline and then set their new names for restore and recovery,
as follows:
run{
sql 'alter database datafile 4, 5 offline';
set newname for datafile 4 to '/u02/dbfile/O12C/users01.dbf';
set newname for datafile 5 to '/u02/dbfile/O12C/users02.dbf';
restore datafile 4, 5;
switch datafile all; # Updates repository with new datafile location.
recover datafile 4, 5;
sql 'alter database datafile 4, 5 online';
}
Starting with Oracle 12c, you no longer need to specify the RMAN sql command when running SQL statements,
such as ALTER DATABASE ; for example,
run{
alter database datafile 4, 5 offline;
set newname for datafile 4 to '/u02/dbfile/O12C/users01.dbf';
set newname for datafile 5 to '/u02/dbfile/O12C/users02.dbf';
restore datafile 4, 5;
switch datafile all; # Updates repository with new datafile location.
recover datafile 4, 5;
alter database datafile 4, 5 online;
}
Search WWH ::




Custom Search