oracle 12c 新特性之一:在线重命名数据文件
oracle 12c 新特性之一:在线重命名数据文件
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
[backcolor=#e56600]/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: 缺失关键字