How to Rename or Move Oracle Tablespace Datafile to Another Location

Oracle database does not provide an easy user interface to rename a datafile of tablespace, nor database administrator can easily move or relocate the datafile to another location or directory that different from original location on creation of database. The rename or move place task has to be performed via Oracle SQLPlus command line interface. However, if the operation is performed when the tablespace which owns the datefile is online, error will occur.

The error message may include the following:

ORA-01511: error in renaming log/data files
ORA-01121: cannot rename database file <string> – file is in use or recovery
ORA-01110: data file <string>: ‘datafile.dbf’

To properly move the datafile around or rename the datafile, follow this guide:

  1. Login to SQLPlus.
  2. Connect as SYS DBA with CONNECT / AS SYSDBA command.
  3. Shutdown the database instance with SHUTDOWN command.
  4. Rename or/and move the datafiles at operating system level.
  5. Start Oracle database in mount state with STARTUP MOUNT command.
  6. Modify the name or location of datafiles in Oracle data dictionary using following command syntax:

    ALTER DATABASE RENAME FILE ‘<fully qualified path to original data file name>’ TO ‘<new or original fully qualified path to new or original data file name>’;

  7. Open Oracle database instance completely with ALTER DATABASE OPEN command.

If the datafiles that need to be changed or moved do not belong to SYSTEM tablespaces, and do not contain active rollback segments or temporary segments, there is another workaround that does not require database instance to be shutdown. Instead, only the particular tablespace that contains the date files is taken offline.

  1. Login to SQLPlus.
  2. Connect as SYS DBA with CONNECT / AS SYSDBA command.
  3. Make offline the affected tablespace with ALTER TABLESPACE <tablespace name> OFFLINE; command.
  4. Modify the name or location of datafiles in Oracle data dictionary using following command syntax:

    ALTER TABLESPACE <tablespace name> RENAME DATAFILE ‘<fully qualified path to original data file name>’ TO ‘<new or original fully qualified path to new or original data file name>’;

  5. Bring the tablespace online again with ALTER TABLESPACE alter tablespace <tablespace name> ONLINE; command.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

oracle move datafile - move datafile oracle - oracle move tablespace - rename datafile - move tablespace oracle - move datafile - move oracle datafile - move tablespace - alter tablespace move datafile - rename tablespace - move oracle datafiles - move tablespace in oracle - moving oracle datafiles - how to move datafile in oracle - alter tablespace rename - oracle move datafiles - change datafile location oracle - oracle rename datafile - ALTER DATAFILE RENAME - oracle change datafile location - oracle tablespace move - move datafile in oracle - mover datafile oracle - mover datafiles en oracle - oracle move datafile online - how to move oracle datafiles - oracle rename datafile online - rename oracle datafile - rename tablespace oracle - rename datafile oracle - move oracle tablespace - how to move oracle datafile - oracle tablespace file location - alter database rename datafile - how to move datafile oracle - oracle move a datafile - moving datafiles in oracle - alter database rename tablespace - datafile rename - ORA-01511: error in renaming log/data files - oracle move data file - move datafiles - oracle move datafile location - how to rename oracle datafile - oracle datafile location - oracle datafile move - mover datafiles oracle - oracle move datafiles online - oracle moving tablespaces - move datafile to another tablespace -