I. Move data files:
-You can use alter database or alter tablespace to move data files.
1. alter database method;
-This method can be used to move data files in any tablespace.
◆ STEP 1. database:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> SHUTDOWN;
SQL> EXIT;
◆ STEP 2. Use the operating system command to move the data file:
-Move the data file 'test. ora 'from the/ora/oracle/data1 directory to the/ora/oracle/data2 directory:
$ Mv/ora/oracle/data1/test. ora/oracle/data2
◆ STEP 3. Mount the DATABASE and use the alter database command to rename the data file:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE RENAME FILE '/ora/oracle/data1/test. ora' TO '/ora/oracle/data2/test. ora ';
◆ STEP 4. Open the database :.
SQL> ALTER DATABASE OPEN;
SQL> SELECT NAME, STATUS FROM V $ DATAFILE;
2. alter tablespace method:
-This method requires that the data file neither belong to the SYSTEM tablespace nor to the tablespace containing the ACTIVE rollback segment or temporary segment.
◆ STEP1. set the tablespace of the data file to OFFLINE:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> ALTER TABLESPACE test OFFLINE;
SQL> EXIT;
◆ STEP2. use the operating system command to move the data file:
Import the data file 'test. ora 'from/ora/oracle/
Move the data1 directory to the/ora/oracle/data2 directory:
$ Mv/ora/oracle/data1/test. ora/oracle/data2
◆ STEP3. use the alter tablespace command to change the data file name:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> ALTER TABLESPACE test RENAME DATAFILE '/ora/oracle/data1/test. ora' TO '/ora/oracle/data2/test. ora ';
◆ Step 4. ONLINE The tablespace where the data file is located:
SQL> ALTER TABLESPACE test ONLINE;
SQL> SELECT NAME, STATUS FROM V $ DATAFILE;
Ii. Mobile control file:
-The control file is specified in the INIT. ORA file. Mobile control files are relatively simple,
-Edit INIT. ORA, move the control file, and restart the database.
◆ STEP 1. database:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> SHUTDOWN;
SQL> EXIT;
◆ STEP 2. Use the operating system command to move the control file:
-Move the control file 'ctl3orcl. ora 'from the/ora/oracle/data1 directory to the/ora/oracle/data2 directory:
$ Mv/ora/oracle/data1/ctrlorcl3.ora/ora/oracle/data2
◆ STEP 3. Edit the INIT. ORA file:
The INIT. ORA file is in the $ ORACLE_HOME/dbs directory,
Modify the parameter "control_files", and specify the moved control file:
Control_files = (/ora/oracle/data1/ctrlorcl1.ora,/ora/oracle/data1/ctrlorcl2.ora,/ora/oracle/data2/ctrlorcl3.ora)
◆ STEP 4. Restart the database:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> STARTUP;
SQL> SELECT name FROM V $ CONTROLFILE;
SQL> EXIT;
3. move online log files:
◆ STEP 1. Stop the database:
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> SHUTDOWN;
SQL> EXIT;
◆ STEP 2. Use the operating system command to move the online log file:
-Move the online Log File 'redolog1. ora 'from the/ora/oracle/data1 directory to the/ora/oracle/data2 directory:
$ Mv/ora/oracle/data1/redolog1.ora/ora/oracle/data2
◆ STEP 3. Mount the DATABASE and use the alter database command to change the online Log File Name :.
$ Sqlplus/nolog
SQL> CONNECT INTERNAL;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE RENAME FILE '/ora/oracle/data1/redolog1.ora' TO '/ora/oracle/data2/redolog1.ora ';
◆ STEP 4. Restart the database :.
SQL> ALTER DATABASE OPEN;
SQL> SELECT MEMBER FROM V $ LOGFILE;