更改Oracle数据文件名字的方法


 在论坛上看到一个经常遇到的问题,移动数据文件,收录一下,以后用得到:

  有两种方法可以更改ORACLE数据文件的名字,联机方法与脱机方法。

  一:脱机(可以移动任何表空间中的数据文件、日志文件,命令为alter database rename file)

  Because the SYSTEM tablespace cannot be taken offline, you must use this method to move data files in the SYSTEM tablespace.

  具体步骤为

      1:$sqlplus “/ as sysdba”
    SQL>shutdown
    2:$mv or move (使用操作系统命令改名字)
    3:$sqlplus “/ as sysdba”
  SQL>startup mount
  SQL>alter database rename file 'xxxxx' to 'xxxxx'


  (注意在alter open之前不要退出)

    4:SQL>alter database open;

  二:联机(不可移动system表空间,回滚段和临时表空间中的数据文件,命令为alter tablespace )

    The following alter tablespace command is applied only to data files in a non-SYSTEM tablespace that does not contain active rollback or temporary segments:

  具体步骤为:

         1:$sqlplus “/ as sysdba”;
  SQL>alter tablespace xxxx offline(如果非归档加drop);
  2:$mv xxxxx xxxxx (用os命令移动数据文件)
  3:SQL>alter tablespace xxxx rename datafile 'xxxx' to 'xxxxx';
  4:SQL>alter tablespace xxxx online;

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3