当前位置:首页 > 网络编程 > 数据库 > Oracle > 更改Oracle数据文件名字的方法

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

点击次数:31 次 发布日期:2008-11-22 16:31:25 作者:源代码网
源代码网推荐

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

  有两种方法可以更改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;

 

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华