How do I rename a data file

在论坛看到一个帖子,说是rename data file 报错了,第一感觉他的语法有问题,也很少用这个命令,就google了一下,发现语法没有问题,可能他的操作顺序有问题。 因为rename的时候数据文件 必须是offline的,或者数据库是mount状态。 

在仔细想了想,以前也整理过一篇rename的文章,不过那篇blog的标题是移动数据文件,和今天的这篇的唯一区别就是在Rename的同时还改了下路径。 还有就是这篇是英文的,就当练习一下英语吧。 

Oracle 移动数据文件的操作方法

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

以下内容引自网络:

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 the SYSTEM tablespace, active rollback segments, or temporary segments, but the procedure can be performed 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.

posted @ 2010-04-14 23:10  davedba  阅读(139)  评论(0编辑  收藏  举报