Rename/Move datafile - Tested in our Test ENV

Tested in our Test ENV

Example: Rename the datafile

(Here i have test by creating the new tablespace with datafile / We can use it for existing datafile to Rename/Move)

SQL> create tablespace newrename datafile '/u01/app/oracle/oradata/prim/newrename.dbf' size 10m;
Tablespace created.

SQL> select name from V$datafile;
NAME

--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/system01.dbf
/u01/app/oracle/oradata/prim/sysaux01.dbf
/u01/app/oracle/oradata/prim/undotbs01.dbf
/u01/app/oracle/oradata/prim/users01.dbf
/u01/app/oracle/oradata/prim/example01.dbf
/u01/app/oracle/oradata/prim/PAP_DATA.dbf
/u01/app/renametest/renametest.dbf
/u01/app/oracle/oradata/prim/newrename.dbf

Make the Tablespace Offline:

SQL> alter tablespace newrename offline;
Tablespace altered.

Rename the File by OS Level (Safer side copy the datafile then rename by using the mv command)

$ cp newrename.dbf newrename.dbf.bck

$ mv newrename.dbf to nrename.dbf

Rename by Sql command:

SQL> alter tablespace newrename rename datafile '/u01/app/oracle/oradata/prim/newrename.dbf' to '/u01/app/oracle/oradata/prim/nrename.dbf';
Tablespace altered.

Make the tablespace online

SQL> alter tablespace NEWRENAME online;
Tablespace altered.
Verify:
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/system01.dbf
/u01/app/oracle/oradata/prim/sysaux01.dbf
/u01/app/oracle/oradata/prim/undotbs01.dbf
/u01/app/oracle/oradata/prim/users01.dbf
/u01/app/oracle/oradata/prim/example01.dbf
/u01/app/oracle/oradata/prim/PAP_DATA.dbf
/u01/app/renametest/renametest.dbf
/u01/app/oracle/oradata/prim/nrename.dbf

Hence it has been rename into the same location of the datafile

Move the datafile into different location:

Create on tablespace with datafile or you can use the existing datafile to perform the operation

Create tablespace renametest datafile ‘/u01/app/oracle/oradata/prim/renametest.dbf’ size 10m;

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/system01.dbf
/u01/app/oracle/oradata/prim/sysaux01.dbf
/u01/app/oracle/oradata/prim/undotbs01.dbf
/u01/app/oracle/oradata/prim/users01.dbf
/u01/app/oracle/oradata/prim/example01.dbf
/u01/app/oracle/oradata/prim/PAP_DATA.dbf
/u01/app/oracle/oradata/prim/renametest.dbf

Make the Tablespace Offline:

SQL> alter tablespace renametest offline;
Tablespace altered.

Move/rename the File by OS Level (Safer side copy the datafile then rename by using the mv command)

$ cp renametest.dbf renametest.dbf.bck

$ mv renametest.dbf /u01/app/renametest/

$ cd /u01/app/renametest/

[oracle@oracledbtest renametest]$ ls

renametest.dbf

Rename by Sql command:

SQL> alter tablespace renametest rename datafile '//u01/app/oracle/oradata/prim/renametest.dbf' to '/u01/app/renametest/renametest.dbf';
Tablespace altered.

Make the tablespace online

SQL> alter tablespace renametest online;
Tablespace altered.

Verify:

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/system01.dbf
/u01/app/oracle/oradata/prim/sysaux01.dbf
/u01/app/oracle/oradata/prim/undotbs01.dbf
/u01/app/oracle/oradata/prim/users01.dbf
/u01/app/oracle/oradata/prim/example01.dbf
/u01/app/oracle/oradata/prim/PAP_DATA.dbf
/u01/app/renametest/renametest.dbf    - Move the datafile into the different location

Hence we move the datafile into the different location

Comments

Post a Comment

Popular posts from this blog

ORA-01110: data file 1: '/oradata/datafiles/system01.dbf'

Expdp from Higher version 12c (12.1.0.2) to lower version 11g (11.2.0.4)

Solutions: error while starting of Oracle Single instance ASM Database