Move database files in Oracle

Source: Internet
Author: User
Tags exit log connect oracle database

Move database files in Oracle

----Oracle database consists of three files of data files, control files, and online log files. Database administrators may consider moving database files because of changes in disk space, or adjustments based on database disk I/O performance. The following is an example of a UNIX platform that discusses the moving methods of three database files.

----one. Moving data files:

----can move data files using ALTER database,alter tablespace two ways.

----1. ALTER database method;

----Use this method, you can move data files for any tablespace.

----Step 1. Down database:

$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > SHUTDOWN;
Svrmgr > EXIT;

----Step 2. Move data files with operating system commands:
----Move the data file ' App1_data.ora ' from the/ora/oracle7/data1 directory to the/ORA/ORACLE7/DATA2 directory:

----$ mv/ora/oracle7/data1/app1_data.ora/ora/oracle7/data2

----Step 3. Mount the database and rename the data file with ALTER DATABASE command:

----$ svrmgrl

Svrmgr > CONNECT INTERNAL;
Svrmgr > STARTUP MOUNT;
Svrmgr > ALTER DATABASE RENAME FILE
2 > '/ora/oracle7/data1/app1_data.ora ' to
3 > '/ora/oracle7/data2/app1_data.ora;

Step 4. Open database:.
Svrmgr > ALTER DATABASE OPEN;
Svrmgr >select name,status from V$datafile;

----2. ALTER Tablespace Method:
----This method, the data file is required to be neither part of the system table space nor a tablespace containing an active rollback segment or a temporary segment.

----STEP1. Offline the table space in which this data file resides:

$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > ALTER tablespace app1_data OFFLINE;
Svrmgr > EXIT;

STEP2. To move a data file with the operating system command:
The data file ' App1_data.ora ' from/ora/oracle7/
The Data1 directory is moved to the/ORA/ORACLE7/DATA2 directory:
$ mv/ora/oracle7/data1/app1_data.ora/ora/oracle7/data2

STEP3. To change the data file name using the ALTER TABLESPACE command:
$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > ALTER tablespace app1_data RENAME datafile
2 > '/ora/oracle7/data 1/app1_data.ora ' to
3 > '/ora/oracle7/data2/app1_data.ora;

STEP4. Put this data file in the Tablespace online:
Svrmgr > ALTER tablespace app1_data ONLINE;
Svrmgr > SELECT name,status from V$datafile;

----two. Mobile Control files:

----control file in INIT. specified in the Ora file. Mobile control files relatively simple, the next database, edit Init.ora, mobile control files, restart the database.

Step 1. Down database:
$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > SHUTDOWN;
Svrmgr > EXIT;

Step 2: Move the control file with the operating system command.
Will control file ' Ctl3orcl.ora ' from/ora/oracle7
The/data1 directory is moved to the/ORA/ORACLE7/DATA2 directory:
$ mv/ora/oracle7/data 1/ctrl3orcl.ora
/ora/oracle7/data2

Step 3. Edit Init.ora File:
Init. Ora files in the $oracle_home/dbs directory,
Modify the parameter "Control_files", which specifies the control file after the move:
Control_files = (/ora/oracle7/data 1/ctrl1orcl.ora,
/ora/oracle7/data1/ctrl2orcl.ora,
/ora/oracle7/data2/ctrl3orcl.ora)

Step 4. To restart the database:
$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > STARTUP;
Svrmgr >select name from V$controlfile;
Svrmgr > EXIT;


----three. Move online log files:
Step 1. To stop a database:
$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > SHUTDOWN;
Svrmgr > EXIT;

Step 2. To move an online log file with the operating system command:
Bring the online log file ' Redolog1.ora ' from/ora/oracle7
The/data1 directory is moved to the/ORA/ORACLE7/DATA2 directory:
$ mv/ora/oracle7/data 1/redolog1.ora
/ora/oracle7/data2

Step 3. Mount database, using ALTER DB
command to change the online log file name:.
$ svrmgrl
Svrmgr > CONNECT INTERNAL;
Svrmgr > STARTUP MOUNT CC1;
Svrmgr > ALTER DATABASE RENAME FILE
2 > '/ora/oracle7/data 1/redolog1.ora ' to
3 > '/ora/oracle7/data 2/redolog1.ora ';

Step 4. Restart database:.
Svrmgr > ALTER DATABASE OPEN;
Svrmgr >select member from V$logfile;



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.