Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Moving Files

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Moving control, log and data files

Controlfiles
1. The current location of the controlfiles can be queried from
the V$CONTROLFILE view, as shown below.

SQL> select name from v$controlfile;

2. In order to rename or move these files we must alter the value of


the control_files instance parameter.

SQL> show parameter control_files

NAME TYPE VALUE


------------------------------------ --------------------------------
------------------------------
control_files string C:\ORACLE\
ORADATA\DB10G\CONTRO
L01.CTL,
C:\ORACLE\ORADATA\DB1
0G\
CONTROL02.CTL, C:\ORACLE\OR
ADATA\
DB10G\CONTROL03.CTL

To move or rename a controlfile do the following.

 Alter the control_files parameter using the ALTER SYSTEM comamnd.


 Shutdown the database.
 Rename the physical file on the OS.
 Start the database.

Logfiles
The current location of the logfiles can be queried from the V$LOGFILE view, as shown
below.

SQL> SELECT member FROM v$logfile;

To move or rename a logfile do the following.

 Shutdown the database.


 Rename the physical file on the OS.
 Start the database in mount mode.
 Issue the ALTER DATABASE RENAME FILE command to rename the file within the
Oracle dictionary.
 Open the database.

datafiles

To move or rename a data file do the following.

 Shutdown the database.


 Rename the physical file on the OS.
 Start the database in mount mode.
 Issue the ALTER DATABASE RENAME FILE command to rename the file within the
Oracle dictionary.
 Open the database.

Procedure for Renaming Datafiles in a Single Tablespace

To rename datafiles in a single tablespace, complete the following steps:

1. Take the tablespace that contains the datafiles offline. The database must be
open.

For example:
ALTER TABLESPACE users OFFLINE NORMAL;

2. Rename the datafiles using the operating system.

3. Use the ALTER TABLESPACE statement with the RENAME DATAFILE clause to change the


filenames within the database.

For example, the following statement renames the


datafiles /u02/oracle/rbdb1/user1.dbf and /u02/oracle/rbdb1/user2.dbf to/u02/oracle/
rbdb1/users01.dbf and /u02/oracle/rbdb1/users02.dbf, respectively:

ALTER TABLESPACE users


RENAME DATAFILE '/u02/oracle/rbdb1/user1.dbf',
'/u02/oracle/rbdb1/user2.dbf'
TO '/u02/oracle/rbdb1/users01.dbf',
'/u02/oracle/rbdb1/users02.dbf';
Always provide complete filenames (including their paths) to properly identify the
old and new datafiles. In particular, specify the old datafile name exactly as it
appears in the DBA_DATA_FILES view of the data dictionary.

4. Back up the database. After making any structural changes to a database,


always perform an immediate and complete backup.

You might also like