Prior to Oracle 12c, moving datafiles has always been an offline task. There were certain techniques you could employ to minimize that downtime, but you couldn’t remove it completely.
Oracle 12c includes an enhancement to the
ALTER DATABASE command to allow datafiles to be moved online. This is one of feature which i liked in Oracle 12c, now if are facing space issue where datafiles reside we can move the datafiles while keeping our database open.
It increases the availability of the database.
The text description of the syntax is shown below, but the syntax diagrams and a full description of the ALTER DATABASE command is available in the documentation here.
ALTER DATABASE MOVE DATAFILE ( ‘filename’ | ‘ASM_filename’ | file_number )
[ TO ( ‘filename’ | ‘ASM_filename’ ) ]
[ REUSE ] [ KEEP ]
The source file can be specified using the file number or name, while the destination file must be specified by the file name. The REUSE keyword indicates the new file should be created even if it already exists. The KEEP keyword indicates the original copy of the datafile should be retained.
When the source file is an OMF file the KEEP option can not be used. If the destination file is an OMF file, the TO clause can be omitted and the file will be created with an OMF name in the DB_CREATE_FILE_DEST location.
The file number can be queried from the
Startup the database where we are planning to change the datafiles location:
Alter database command will move the file from 1 location to different location, we need to make sure that the location should exist where we are planning to move the file.
After the file is moved, original file will not be there because it has been moved to new location.
Hope it helps..
Thanks for viewing.