Wednesday, January 27, 2010

How to rename a file with junk characters

In our case file name /u42/oradata/ilproddata/a_txn_ind364.dbf; is having the junk character.


Step 1: Find the name of the junk character file.


a) On database


Select name from v$datafile where name like '%/u42/oradata/ilproddata/a_txn_ind364%';

/u42/oradata/ilproddata/a_txn_ind364.dbf;


b) On the mount point


cd /u42/oradata/ilproddata

ls -ltr a_txn_ind364*

a_txn_ind364.dbf;


Step 2:


Now shutdown the database


Step 3:


Now copy the file to the new name. It's better to use copy, always avoid move command in such case.


cd /u42/oradata/ilproddata

cp a_txn_ind364.dbf* a_txn_ind364.dbf


Step 4: Open the database in mount mode and run the rename command

As the file have junk characters. So find the exact name of the file with junk characters.


a) Take the trace of control file using “alter database backup controlfile to trace;”


b) Now open the file trace file in VI mode and search the name "a_txn_ind364.dbf;"


c) Remove all the lines except this and make the changes as mentioned below.


[ilerpdb01: oraprod] /u11/app/ilproddb/9.2.0/admin/ILPROD_ilerpdb01/udump> more ilprod_ora_987810.trc


alter database rename file '/u42/oradata/ilproddata/a_txn_ind364.dbf;^[[1~^[[1' to '/u42/oradata/ilproddata/a_txn_ind364.dbf' ;


d) Now run the scripts "ilprod_ora_987810.trc" on the sql prompt.


e) Now open the database.