Rename or Re-locate Datafiles


Ensure you have adequate backups to recover if something goes wrong.

A tablespace can consist of a number of datafiles. On many occasions it becomes necessary to re-locate or rename datafiles.

For example, you have the tablespace USERS, that consists of the single datafile /u03/oradata/PORTAL/users01.dbf.      

To rellocate the datafile to the location /u05/oradata/PORTAL/users01.dbf perform the following steps

Connect to the database as SYSTEM.

sqlplus system/password

Offline the USERS tablespace:

ALTER TABLESPACE users OFFLINE;


Copy or Move the datafile to the new location at the OS file system level:

!cp /u03/oradata/PORTAL/users01.dbf        /u05/oradata/PORTAL/users01.dbf


Rename the datafile on Oracle:

ALTER DATABASE RENAME FILE      '/u03/oradata/PORTAL/users01.dbf'
TO                                               '/u05/oradata/PORTAL/users01.dbf';

 

Bring the USERS tablespaceOnline :

ALTER TABLESPACE users ONLINE;

SELECT tablespace_name, file_name FROM dba_data_files;