IT开放社区

RMAN set newname更换数据文件位置及文件名实验

环境:

OS:Oracle Linux Server release 5.6

DB:oracle11.2.0.1

1.创建一个新的表空间用于实验;

itkaifang@SYS> create tablespace txt datafile'/u01/app/oracle/oradata/itkaifang/txt01.dbf' size 10M;
Tablespace created.
itkaifang@SYS> select file_name from dba_data_files where tablespace_name='TXT';
FILE_NAME
--------------------------------------------------
/u01/app/oracle/oradata/itkaifang/txt01.dbf
itkaifang@SYS>

2.使用RMAN工具更换数据文件位置及文件名;

[oracle@itkaifang ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Apr 8 16:38:25 2017
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ITKAIFAN (DBID=3506788363)
RMAN>
RMAN> run {
2> sql "alter tablespace txt offline immediate";
3> set newname for datafile'/u01/app/oracle/oradata/itkaifang/txt01.dbf' to '/home/oracle/txt1.dbf';
4> restore tablespace 'TXT';
5> switch datafile all;
6> recover tablespace 'TXT';
7> sql "alter tablespace txt online";
8> }
sql statement: alter tablespace txt offline immediate
executing command: SET NEWNAME
Starting restore at 08-APR-17
using channel ORA_DISK_1
creating datafile file number=7 name=/home/oracle/txt1.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 08-APR-17
datafile 7 switched to datafile copy
input datafile copy RECID=3 STAMP=940783454 file name=/home/oracle/txt1.dbf
Starting recover at 08-APR-17
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 08-APR-17
sql statement: alter tablespace txt online
RMAN>

3.验证;

itkaifang@SYS> select file_name from dba_data_files where tablespace_name='TXT';
FILE_NAME
--------------------------------------------------
/home/oracle/txt1.dbf
itkaifang@SYS>

---End---Good Luck---

相关文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

网站分类
站点信息
  • 文章总数:119
  • 页面总数:2
  • 分类总数:3
  • 标签总数:12
  • 评论总数:2
  • 浏览总数:116129
友情链接

BlogPowerBy Z-BlogPHP 1.5 Zero ;Theme By 爱墙纸

Copyright © 2020-2030 ITkaifang.COM All Rights Reserved. 京ICP备13044647号.Email:dreamerqin@qq.com