Using New SET NEWNAME Clauses

Restoring Data Files to Nondefault Locations:–

Using SET NEWNAME for Switching Files :–

 The SET NEWNAME command can be used only inside a RUN block. It prepares a name mapping for subsequent operations. In the example given below, the SET NEWNAME command defines the location where a restore operation of that data file will be written. When the RESTORE command executes, the users01.dbf data file is restored to /disk2/users01.dbf. It is written there, but the control file is still not pointing to that location. The SWITCH command causes the control file to be updated with the new location.

A more efficient way is to use the SET NEWNAME clause to specify the default name format for all data files in a named tablespace and all data files in the database (rather than setting file names individually, which was in database versions prior to Oracle Database 11gR2 (11.2).

The order of precedence for the SET NEWNAME command is as follows:

 

  1. SET NEWNAME FOR DATAFILE and SET NEWNAME FOR TEMPFILE
  2. SET NEWNAME FOR TABLESPACE
  3. SET NEWNAME FOR DATABASE

 

RMAN> STARTUP MOUNT;

RMAN> RUN

{

SET NEWNAME FOR DATAFILE 4 TO ‘/u02/USERS01.DBF’;

SET NEWNAME FOR DATAFILE 5 TO ‘/u02/TOOLS01.DBF’;

RESTORE DATAFILE 4, 5;

SWITCH DATAFILE ALL; # UPDATE CONTROL FILE WITH NEW FILE NAMES.

RECOVER DATAFILE 4, 5;

SQL ‘ALTER DATABASE OPEN’;

}

If database is open then put data file offline then do this:–

 

RMAN> RUN

{

ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;

ALLOCATE CHANNEL ch2 DEVICE TYPE DISK

SQL “ALTER TABLESPACE users OFFLINE IMMEDIATE”;

SET NEWNAME FOR DATAFILE ‘/u01/app/oracle/oradata/ORCL/users01.dbf ‘ TO ‘/u02/users01.dbf ‘;

RESTORE TABLESPACE users;

SWITCH DATAFILE ALL;

RECOVER TABLESPACE users;

SQL “ALTER TABLESPACE users ONLINE”;

}

 

 

RMAN> RUN

{

ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;

SQL ‘ALTER DATABASE DATAFILE 4, 5 OFFLINE’;

SET NEWNAME FOR DATAFILE 4 TO ‘/u02/USERS01.DBF’;

SET NEWNAME FOR DATAFILE 5 TO ‘/u02/TOOLS01.DBF’;

RESTORE DATAFILE 4, 5;

SWITCH DATAFILE ALL;     # UPDATE CONTROL FILE WITH NEW FILE NAMES.

RECOVER DATAFILE 4, 5;

SQL ‘ALTER DATABASE DATAFILE 4, 5 ONLINE’;

}

 

If you don’t run the switch command, RMAN marks the restored data file to be a valid data file copy that can be used for subsequent restore operations.

 

Substitution Variables for SET NEWNAME :–

 %b = Specifies the file name without the directory path *NEW*

%f = Specifies the absolute file number of the data file for which the new name is generated

%I = Specifies the DBID

%N= Specifies the tablespace name

%U = Specifies a system-generated file name of the format:  data-D-%d_id-%I_TS-%N_FNO-%f

 

Thank you for reading…….This is Airy …..Enjoy

#rman, #set-new-name-clause