Sunday, July 12, 2009

Rename Oracle Datafile

Option 1: Tablespace datafile rename (the tablespace need to be offline)

We can use the alter tablespace rename datafile command.You must re-name the data file while the tablespace is offline.

SQL> ALTER TABLESPACE cust_ts OFFLINE;
OS $ mv 'OLDFILE.DBF ' 'NEWFILE.DBF'
SQL> ALTER TABLESPACE users RENAME datafile '/u01/app/oracle/mysid/oldname.dbf' TO '/u01/app/oracle/mysid/newname.dbf';

Option 2: Database datafile rename (Shutdown DB is required)

We can also use the alter database rename datafile command.
The data file must be renamed in the OS (using the mv unix command) while the database is down.
And the rename data file must be done while the database is un-opened (in the mount stage):

SQL> shutdown immediate;
OS $ mv 'OLDFILE.DBF ' 'NEWFILE.DBF'
SQL> startup mount;
SQL> ALTER DATABASE RENAME file '/u01/app/oracle/mysid/oldname.dbf' TO '/u01/app/oracle/mysid/newname.dbf';

No comments:

Post a Comment