Ways to move data files

Source: Internet
Author: User

Sometimes the i/0 of a disk may be too busy, which may affect the overall efficiency of the database system. At this point, you should move one or several data files to a different disk to balance the I/O to the disk. In addition, you should consider moving data files in case of disk corruption. Oracle provides two of instructions for moving data files.

I. Moving non-system data files

Alter Tablespace Tablespace_name

Rename datafile ' file_name.dbf '

To ' file_name.dbf ';

This statement is appropriate for data files in non-system tablespaces that do not have active restore data or temporary data segments above, requiring that the target tablespace must be offline and the destination data file must exist before using the statement. Because the statement modifies only the pointer (address) to the data file in the control file

The steps are as follows (for example, moving the Users table space):

1. Get information about table space and data files

Select File_name,tablespace_name,status from Dba_data_files; Determine the status of the data files and files for the corresponding tablespace, and be aware of the fact that there are multiple data files in the tablespace.

Select Tablespace_name,status from dba_tablespaces; determine if the tablespace is online

2. Set the table space offline

Alter TABLESPACE users offline

The offline state is intended to allow other processes to modify data in the data file while the data file is being moved. Ensure the integrity of the data after the move

3. Use OS commands to move or copy data files to be moved

You must ensure that the data file is really moved or copied to the current location, because the modification statement does not verify that the data file exists and available it, but only modifies the pointer information of the data file in the control file.

4. Execute the command to modify the data file

Alter TABLESPACE users

Rename datafile '/oradta/orcl/users01.dbf '

To '/oradta/orcl/datafile/data/users01.dbf ';

5. Place the table space online

Alter tablespace users online;

6, access to table space and data files related information dba_tablespaces, dba_data_files;

Select File_name,tablespace_name,status from Dba_data_files; Determine the status of data files and files for the corresponding tablespace

Select Tablespace_name,status from dba_tablespaces; determine if the tablespace is online

7. Delete the old data file.

Second, mobile system data files and temporary, restore data files

1. ALTER DATABASE database_name

Rename file ' data_file_name.dbf '

To ' data_file_name.dbf ';

This command applies to both the system tablespace and the data file in the tablespace that cannot be placed offline, requiring that the database must be running in the loaded state of Mount, and that the destination data file must exist because the statement modifies only the pointer (address) of the data file in the control file and does not verify that the data file exists.

The steps are as follows (in the case of moving system table spaces):

1. Get information about tablespaces and data files

    

Select File_name,tablespace_name,status from Dba_data_files; Determine the status of the data files and files for the corresponding tablespace, and be aware of the fact that there are multiple data files in the tablespace.

Select Tablespace_name,status from dba_tablespaces; determine if the tablespace is online

2. Close the database system

Shutdown immediate

Ensure that the database is completely shut down and that no process can modify the system tablespace. Because the system, temporary, and restore tablespace cannot be taken offline, the database must be closed.

3. Use OS commands to move or copy data files to the destination address.

4. Set the database to load state mount

Startup Mount

Note

Start the database as a load, which is also a special database state.   This state is used during certain special maintenance periods for the database, such as restoring the system tablespace, modifying the data file name, moving the data file, and so on. Startup command for startup Mount;

Oracle initiates an instance and opens the control file when the database is started with the Mount command at this point Oracle does the following:

1. Associating a database with an instance that has already been started

2. Use the instructions in the initialization parameters file to lock and open the control file

3. Read the control file and obtain the name and status information of the data file and redo log file, but do not check the existence of these files

5. Execute the Mobile data File command

ALTER DATABASE database_name

Rename file ' file_name.dbf '

To ' file_name.dbf '

6. Open the database system

ALTER DATABASE Open

7, through the Dba_data_files data dictionary to view the corresponding data file in the table space.

8. Delete old useless data files.

Then use the same method to move the data files of the staging tablespace and the data files of the restore tablespace to the specified directory. Complete the configuration of the data files for the Oracle system.

  

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.