Thursday, October 7, 2010

Move location of Oracle Data File (.dbf) file

I faced space crunch issue on one of the Oracle Server. Oracle is installed on c: and virtually no space is left in c drive however d: drive have dozens of space left so we decided a simple workaround to change the location of some of the oracle data file from c drive to d drive. Here are the simple steps to perform it.

Shut down the Oracle 
SQL> shutdown immediate;

Manually move the .dbf files
I copied SYSTEM01.DBF file from C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF to D:\Oradata\. However you can copy all the .dbf files depending upon your requirement and space in target directory.

Restart the Oracle 
SQL>startup mount;

Alter the database
SQL> ALTER DATABASE RENAME FILE 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF' TO 'D:\ORADATA\SYSTEM01.DBF';

Check the database
Fire the following query to check weather the changes are correct.
SQL>Select name from v$datafile;
Verify your .dbf file ; it must have the changed path now.

Open the altered Database
SQL> alter database open;


This might not be the best approach to solve the space issue but can be handy as a quick workaround.