ASM files can be renamed like any other files in a standard filesystem. For ASM, rename is performed through some type of statements (ADD ALIAS, RENAME ALIAS, ADD DIRECTORY) to manipulate filenames, alias, and directories.
Renaming datafiles is sometimes needed when database file names still contain old database name after a database on ASM is renamed (for example with nid). Then, it is required to change ASM datafile names accordingly with the new database name. RMAN backup copy doesn’t work in this case as file still remains in the same diskgroup.
Follow the steps given below to perform such a rename.
Changes at ASM Instance
1. Create directory names within diskgroup.
alter diskgroup dg1 add directory '+dg1/[new_dir_name]'; alter diskgroup dg1 add directory '+dg1/[new_dir_name]/[datafile]';
For Example:
old datafile name: +DG1/ee1020/datafile/books.256.652915493 new datafile name: +DG1/DD1020/datafile/books.dbf
alter diskgroup dg1 add directory '+DG1/DD1020'; alter diskgroup dg1 add directory '+DG1/DD1020/datafile';
2. Create an alias for the target datafile name with new path and filename
alter diskgroup dg1 add alias '[fully_qualified_new_data_file_name]' for '[fully_qualified_old_data_file_name]';
For Example:
alter diskgroup dg1 add alias '+DG1/DD1020/datafile/books.dbf' for '+DG1/ee1020/datafile/books.256.652915493';
Change at Database instance
1. Startup database in mount mode and rename the datafile. To use this clause for a datafile or tempfile, the database needs to be in mount mode. The database can also be open, but the datafile or tempfile being renamed must be offline.
startup mount
alter database rename file '[fully_qualified_old_data_file_name]' to '[fully_qualified_new_data_file_name]';
For Example:
alter database rename file '+DG1/ee1020/datafile/books.256.652915493' to '+DG1/DD1020/datafile/books.dbf';
For Example:
alter diskgroup dg1 rename alias '+DG1/DD1020/datafile/books.dbf' to '+DG1/DD1020/datafile/books2.dbf';