oracle 12c 新特性之一:線上重新命名資料檔案

paulyibinyi發表於2013-12-06
  oracle 12c 新特性之一,可以線上重新命名資料檔案, 在12c版本之前,如果出現資料檔案建立放錯目錄,或本來是放到asm中,由於漏寫加號等等,而放到了檔案系統中,而不得不申請停機時間
來做資料檔案的遷移。 到了12c,這個操作就變的非常簡單了,而且是線上的,對業務沒有任何影響,提高了系統的高可用性。
 
以下是具體實驗操作過程:

[oracle@db12c ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.1.0 Production on Fri Dec 6 16:19:18 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oradata/orcl/system01.dbf
/oradata/orcl/pdbseed/system01.dbf
/oradata/orcl/sysaux01.dbf
/oradata/orcl/pdbseed/sysaux01.dbf
/oradata/orcl/undotbs01.dbf
/oradata/orcl/users01.dbf
/oradata/ORCL/datafile/pdb1/system01.dbf
/oradata/ORCL/datafile/pdb1/sysaux01.dbf
/oradata/ORCL/datafile/pdb1/users01.dbf

9 rows selected.

SQL>

把/oradata/orcl/users01.dbf重新命名到'/oradata/ORCL/datafile/pdb1/users02.dbf';

SQL> alter database move datafile '/oradata/orcl/users01.dbf' to '/oradata/ORCL/datafile/pdb1/users02.dbf';

Database altered.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oradata/orcl/system01.dbf
/oradata/orcl/pdbseed/system01.dbf
/oradata/orcl/sysaux01.dbf
/oradata/orcl/pdbseed/sysaux01.dbf
/oradata/orcl/undotbs01.dbf
/oradata/ORCL/datafile/pdb1/users02.dbf
/oradata/ORCL/datafile/pdb1/system01.dbf
/oradata/ORCL/datafile/pdb1/sysaux01.dbf
/oradata/ORCL/datafile/pdb1/users01.dbf

9 rows selected.

SQL>

在資料庫日誌中也會有記錄的
Fri Dec 06 16:21:30 2013
alter database move datafile '/oradata/orcl/users01.dbf' to '/oradata/ORCL/datafile/pdb1/users02.dbf'
Fri Dec 06 16:21:30 2013
Moving datafile /oradata/orcl/users01.dbf (6) to /oradata/ORCL/datafile/pdb1/users02.dbf
Move operation committed for file /oradata/ORCL/datafile/pdb1/users02.dbf
Completed: alter database move datafile '/oradata/orcl/users01.dbf' to '/oradata/ORCL/datafile/pdb1/users02.dbf'。





在oracle 11g中 這個命令是失效的

C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期五 12月 6 16:37:55 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------

C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\MACLEAN01.DBF


SQL> alter database move datafile 'C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
' to 'C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS02.DBF';
alter database move datafile 'C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF' to
'C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS02.DBF'
                    *
第 1 行出現錯誤:
ORA-00905: 缺失關鍵字


SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-1062558/,如需轉載,請註明出處,否則將追究法律責任。

相關文章