How do I rename a data file

Source: Internet
Author: User

I saw a post in the Forum saying that the rename data file reported an error. First, I felt that there was a problem with his syntax, and I rarely used this command. I went to Google and found that the syntax was correct, the operation sequence may be incorrect. This is because the data file must be offline or the database is in the Mount state during rename.

After thinking carefully, I have also compiled a RENAME article before. However, the title of the blog is a mobile data file, the only difference between this and today's article is that while rename is also changed. Another reason is that this article is in English. Just practice it.

How to operate Oracle mobile data files

Http://blog.csdn.net/tianlesoftware/archive/2009/11/30/4899172.aspx

The following content is derived from the network:

Datafiles can be moved or renamed using one of two methods: Alter database or alter tablespace.

The main difference between them is that alter tablespace only applies to datafiles that do not contain in the system tablespace, active rollback segments, or temporary segments, but the procedure can be saved med while the instance is still running. the alter database method works for any datafile, but the instance must be shut down.

1. The alter database method:

1. Shut down the instance.

2. Rename and/or move the datafile using operating system commands.

3. mount the database and use alter databaseto rename the file within the database. A fully qualified filename is required in the syntax of your operating system. for example to rename a file called 'data01. DBF 'to 'data04.dbf' and move it to a new location at the same time (at this point in the example the instance has been shutdown) and;

4. Start the instance.

Svrmgr> connect sys/Oracle AS sysdba;

Svrmgr> startup Mount U1;

Svrmgr> alter databaserename File '/u01/Oracle/u1/data01.dbf' to '/u02/Oracle/u1/data04.dbf ';

Svrmgr> alter database open;

Notice the single quotes around the fully qualified filenames and remember, the files must exist at the Source and Destination paths. The instance is now open using the new location and name for the datafile.

2. The alter tablespacemethod:

This method has the advantage that it doesn't require shutting down the instance, but it only works with non-system tablespaces. further, it can't be used for tablespaces that contain active rollback segments or temporary segments.

1. Take the tablespace offline.

2. Rename and/or move the datafile using operating system commands.

3. Use the alter tablespacecommand to rename the file in the database.

4. Bring the tablespace back online.

Svrmgr> connect sys/Oracle AS sysdba

Svrmgr> alter tablespace app_data offline;

Svrmgr> alter tablespace app_date rename datafile '/u01/Oracle/u1/data01.dbf' to '/u02/Oracle/u1/data04.dbf ';

Svrmgr> alter tablespace app_data online;

The tablespace will be back online using the new name and/or location of the datafile.

Both of these methodologies can be used within Oracle Enterprise Manager also.

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.