Chinaunix首页 | 论坛 | 博客
  • 博客访问: 535163
  • 博文数量: 63
  • 博客积分: 1194
  • 博客等级: 中士
  • 技术积分: 761
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-24 12:44
个人简介

得之坦然,失之淡然,争其必然,顺其自然!

文章分类

全部博文(63)

文章存档

2014年(2)

2013年(22)

2012年(39)

分类: Oracle

2012-11-23 11:33:23

利用RMAN移动数据文件,移动步骤如下:
查看现有数据文件:

点击(此处)折叠或打开

  1. SQL> select file#,status,name from v$datafile;

  2.      FILE# STATUS NAME

  3.          1 SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf
  4.          2 ONLINE /u01/app/oracle/oradata/orcl/sysaux01.dbf
  5.          3 ONLINE /u01/app/oracle/oradata/orcl/undotbs01.dbf
  6.          4 ONLINE /u01/app/oracle/oradata/orcl/users01.dbf
  7.          5 ONLINE /u01/app/oracle/oradata/orcl/example01.dbf
  8.          6 ONLINE /u01/app/oracle/oradata/orcl/test01.dbf
  9.          7 ONLINE /u01/app/oracle/product/rcat.dbf
  10.          8 ONLINE /u01/app/oracle/oradata/orcl/hrtest01.dbf

  11. 8 rows selected.

以数据文件test01.dbf(6号文件)为例,将其移动到上级目录(写法1):

点击(此处)折叠或打开

  1. RMAN> sql 'alter database datafile 6 offline';

点击(此处)折叠或打开

  1. run {
  2. copy datafile 6 to '/u01/app/oracle/oradata/test01.dbf';
  3. switch datafile 6 to datafilecopy '/u01/app/oracle/oradata/test01.dbf';
  4. recover datafile 6;
  5. }
对数据文件执行set newname操作(写法2):

点击(此处)折叠或打开

  1. run {
  2. set newname for datafile 6 to '/u01/app/oracle/oradata/test01.dbf';
  3. restore datafile 6;
  4. switch datafile 6;
  5. recover datafile 6;
  6. }



此时在sqlplus下查询数据文件的状态:

点击(此处)折叠或打开

  1. SQL> select file#,status,name from v$datafile;

  2.      FILE# STATUS NAME

  3.          1 SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf
  4.          2 ONLINE /u01/app/oracle/oradata/orcl/sysaux01.dbf
  5.          3 ONLINE /u01/app/oracle/oradata/orcl/undotbs01.dbf
  6.          4 ONLINE /u01/app/oracle/oradata/orcl/users01.dbf
  7.          5 ONLINE /u01/app/oracle/oradata/orcl/example01.dbf
  8.          6 OFFLINE /u01/app/oracle/oradata/test01.dbf
  9.          7 ONLINE /u01/app/oracle/product/rcat.dbf
  10.          8 ONLINE /u01/app/oracle/oradata/orcl/hrtest01.dbf

  11. 8 rows selected.

在RMAN中修改数据文件状态为在线:

点击(此处)折叠或打开

  1. RMAN> sql 'alter database datafile 6 online';

  2. sql statement: alter database datafile 6 online
再次查看数据文件状态:

点击(此处)折叠或打开

  1. SQL> select file#,status,name from v$datafile;

  2.      FILE# STATUS NAME

  3.          1 SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf
  4.          2 ONLINE /u01/app/oracle/oradata/orcl/sysaux01.dbf
  5.          3 ONLINE /u01/app/oracle/oradata/orcl/undotbs01.dbf
  6.          4 ONLINE /u01/app/oracle/oradata/orcl/users01.dbf
  7.          5 ONLINE /u01/app/oracle/oradata/orcl/example01.dbf
  8.          6 ONLINE /u01/app/oracle/oradata/test01.dbf
  9.          7 ONLINE /u01/app/oracle/product/rcat.dbf
  10.          8 ONLINE /u01/app/oracle/oradata/orcl/hrtest01.dbf

  11. 8 rows selected.
ok,数据文件移动成功!
阅读(1672) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~