Rename/move a datafile - Oracle Database Script. --------------- For oracle 12c, move or rename of datafile can be done online with one line: SQL> alter database move datafile '/home/oracle/producing1.dbf' to '/home/oracle/app/oracle/oradata/cdb1/testin1.dbf'; -- -------------For 11g, u have to follow below steps:( It needs downtime for the datafile) --Make the tablespace offline: alter database datafile '/home/oracle/app/oracle/oradata/cdb1/testin1.dbf' offline; -- Move the file physically to a new location. mv /home/oracle/app/oracle/oradata/cdb1/testin1.dbf /home/oracle/producing1.dbf -- Rename at db level alter database rename file '/home/oracle/app/oracle/oradata/cdb1/testin1.dbf' to '/home/oracle/producing1.dbf'; -- Recover the datafile: recover datafile 37; -- Make the datafile online: alter database datafile '/home/oracle/producing1.dbf' online;
--------------- For oracle 12c, move or rename of datafile can be done online with one line: SQL> alter database move datafile '/home/oracle/producing1.dbf' to '/home/oracle/app/oracle/oradata/cdb1/testin1.dbf'; -- -------------For 11g, u have to follow below steps:( It needs downtime for the datafile) --Make the tablespace offline: alter database datafile '/home/oracle/app/oracle/oradata/cdb1/testin1.dbf' offline; -- Move the file physically to a new location. mv /home/oracle/app/oracle/oradata/cdb1/testin1.dbf /home/oracle/producing1.dbf -- Rename at db level alter database rename file '/home/oracle/app/oracle/oradata/cdb1/testin1.dbf' to '/home/oracle/producing1.dbf'; -- Recover the datafile: recover datafile 37; -- Make the datafile online: alter database datafile '/home/oracle/producing1.dbf' online;