Two Simple Methods to Move/Rename Oracle DB Data Files

First Method (must be done as sysdba):

1. First, shut down the database: “shutdown immediate;”
2. Rename and/or move data files to new destination using OS commands (e.g. mv for linux)
3. Startup DB in mount mode: “startup mount;”
4. Change data files names from the DB: “alter database rename file ‘ old_absolute_path_to_old_file_including_filename’ TO ‘new_absolute_path_to_old_file_including_filename’ ;”
5. Open the DB: “alter database open;”

Second Method (must be done as sysdba as well):

1. Take the tablespace offline: “alter tablespace app_data offline;”
2. Rename and/or move data files to new destination using OS commands (e.g. mv for linux)
3. Use the alter tablespace command to rename the file in the database: “alter tablespace tablespace_name rename datafile ‘ old_absolute_path_to_old_file_including_filename’ TO ‘new_absolute_path_to_old_file_including_filename’ ;”
4. Bring the tablespace back online: “alter tablespace tablespace_name online;”

Advantage of the second over the first is that you don’t need to bring the whole DB down, only the tablespace, however I still prefer the first 🙂

Note: To get the names of the existing Data Files, use the following query: “select name from v$datafile;”

Source: Ahmed Ismail

About SoCRaT

Software Engineer, OSS & Linux Geek
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s