Recently I was asked to rename a tablespace. The environment was Oracle version 11.2.0.3 (both database and clusterware/ASM).

This is the test case I build to understand how that works:
(I couldn’t find a clean, straightforward description how to do that, which is why I blog it here)

I created an empty tablespace ‘test1′ for test purposes:

SYS@v11203 AS SYSDBA> create bigfile tablespace test1 datafile size 10m;

(I use bigfile tablespaces only with ASM. Adding datafiles is such a labour intensive work, bigfile tablespaces elimenate that, when auto extent is correctly set)

A tablespace can be easily renamed with the alter tablespace rename command:

SYS@v11203 AS SYSDBA> alter tablespace test1 rename to test2;

This changes the Oracle data dictionary to reflect a new name. This doesn’t touch the underlying datafile.

To rename the datafile in ASM, offline the tablespace, copy the datafile using RMAN, rename the datafile in the Oracle data dictionary, and online the tablespace again:

Offline the tablespace:

SYS@v11203 AS SYSDBA> alter tablespace test2 offline;

Copy the datafile using RMAN:

RMAN> copy datafile '+DATA/v11203/datafile/test1.268.789380535' to '+DATA';

Starting backup at 23-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=+DATA/v11203/datafile/test1.268.789380535
output file name=+DATA/v11203/datafile/test2.269.789380645 tag=TAG20120723T082404 RECID=1 STAMP=789380644
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 23-JUL-12

Rename the datafile in the Oracle data dictionary:

SYS@v11203 AS SYSDBA> alter database rename file '+DATA/v11203/datafile/test1.268.789380535' to '+DATA/v11203/datafile/test2.269.789380645';

Please mind the ‘old’ filename is at ‘input datafile’, and the ‘new’ filename is at ‘output file name’ with the RMAN output.

Next, and finally: online the tablespace:

SYS@v11203 AS SYSDBA> alter tablespace test2 online;

(the old datafile is gone)

Update:

The RMAN copy command and data dictionary update could also be done with RMAN backup as copy and switch datafile:

Status of the database after renaming:

SYS@v11203 AS SYSDBA> select file_id, file_name, tablespace_name from dba_data_files;

Offline the tablespace (my database is in NOARCHIVELOG, online backup (as copy) can only be done in ARCHIVELOG, when doing so, the datafile needs recovery):

RMAN> sql "alter tablespace test2 offline";

sql statement: alter tablespace test2 offline

Backup the datafile as copy. It is very convenient to use file number (file_id), this makes it much simpler to do this:

RMAN> backup as copy datafile 7 format '+DATA';

Starting backup at 23-JUL-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=+DATA/v11203/datafile/test1.269.789411511
output file name=+DATA/v11203/datafile/test2.268.789411665 tag=TAG20120723T170105 RECID=2 STAMP=789411665
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 23-JUL-12

Now switch to the backup copy:

RMAN> switch datafile 7 to copy;

datafile 7 switched to datafile copy "+DATA/v11203/datafile/test2.268.789411665"

And online the tablespace again:

RMAN> sql "alter tablespace test2 online";

sql statement: alter tablespace test2 online

Please mind this leaves the old datafile in place, so it needs to be removed explicitly:

RMAN> delete noprompt copy of datafile 7;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK
List of Datafile Copies
======================= Key File S Completion Time Ckp SCN Ckp Time
------- ---- - --------------- ---------- ---------------
5 7 A 23-JUL-12 1779771 23-JUL-12
Name: +DATA/v11203/datafile/test1.268.789415137 deleted datafile copy
datafile copy file name=+DATA/v11203/datafile/test1.268.789415137 RECID=5 STAMP=789415216
Deleted 1 objects

An alternative is to do this with asmcmd, but it’s far less elegant:

$ asmcmd rm -f +DATA/v11203/datafile/test1.269.789411511

Rename Oracle Managed File (OMF) datafiles in ASM(ZT)的更多相关文章

  1. ORACLE managed file(OMF)

    ORACLE managed file (OMF) Oracle自动创建和删除OMF文件 不用操心文件的命名约定 在手动管理文件时容易错误删除数据文件(OMF降低这种风险) Oracle自动删除不再需 ...

  2. Oracle管理文件OMF (oracle managed files)

    简化dba的管理操作 1:启用 omf 23:16:04 SYS@orcl> show parameter DB_CREATE_FILE_DEST NAME TYPE VALUE ------- ...

  3. [置顶] How to create Oracle 11g R2 database manually in ASM?

    Step 1: Specify an Instance Identifier (SID) export ORACLE_SID=maomi Step 2: Ensure That the Require ...

  4. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.2.Oracleasm Createdisk ASM磁盘失败:Instantiating disk: failed

    1.错误信息:Instantiating disk: failed [root@linuxrac1 /]# /usr/sbin/oracleasm createdisk OCR_VOTE /dev/s ...

  5. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.1.安装并配置ASM驱动

    3.1.安装并配置ASM驱动 3.3.1.检查内核 [root@linuxrac2 etc]# uname -r 2.6.18-164.el5 下载以下rpm包(注意rpm包版本和Linux内核版本一 ...

  6. ORACLE CONTROL FILE 笔记

    控制文件包含的信息:   1.数据库的名字   2.联机重做日志文件和数据文件的名字和位置   3.数据库创建的时间戳   4.当前日志的序列号   5.检查点信息   6.备份信息   TIP:数据 ...

  7. Oracle 11gR2用gpnp profile存放ASM的spfile路径

    从Oracle 11gR2开始,GI集成了ASM,OCR/VOTEDISK也存放在ASM磁盘组了(11gR2以前需要存放于裸设备中),同时ASM的功能较10g也有很大增强. 我们先引入一个问题:11g ...

  8. Oracle 11gR2 RAC DBCA无法识别ASM磁盘组(ORA-19504,ORA-15045,ORA-17502,ORA-15081)

    ORA-19504: failed to create file "+DATA" ORA-15045: ASM file name '+DATA' is not in refere ...

  9. oracle RAC如何正确地删除ASM磁盘组

    1.登录到命令行 切换到grid用户 [grid@swnode1 ~]$ sqlplus / as sysasm SQL*Plus: Release Production on Wed May :: ...

随机推荐

  1. java学习小笔记(三.socket通信)【转】

    三,socket通信1.http://blog.csdn.net/kongxx/article/details/7288896这个人写的关于socket通信不错,循序渐进式的讲解,用代码示例说明,运用 ...

  2. Codeforces Round #412 div2 ABCD

    A 按rank给出每个人的赛前分数和赛后分数 如果一个人打败了比他分数高的人 他的分数必然升高 问比赛rated吗 如果一个人的分数改变了肯定rate 如果全都没改的话 也可能是rated 这时候ch ...

  3. RPM和yum相关

    写在前面: 在这里可以知道rpm和yum的基本用法,找到更新本地yum源.搭建yum源的方法以及yum很琐碎的东西,包括yum源的优先级.用yum来安装或卸载CentOS图形界面包以及保存yum下载的 ...

  4. struts2常见配置解决错误There is no mapped for namespace[/] and action name

    我碰到这个错误的原因是我把配置文件名写成了Struts.xml,改成struts.xml就可以了. 在确定struts.xml本身并没有写错的情况下,那么发生错误有可能是路径,配置文件名. 如果实在找 ...

  5. linux下图形字符的命令

    banner sudo apt-get install sysvbanner banner song 若更改字体可以使用banner song printerbanner -w 50 A toilet ...

  6. GridView1 footer求和

    // ShowFooter="True" private double sum = 0;//取指定列的数据和,你要根据具体情况对待可能你要处理的是int protected voi ...

  7. nvm工具

    nvm工具 nvm简介 nvm是node version manager的简称,是nodeJs的版本管理器,他可以在一台主机上对node的版本进行方便的切换.我尝试了一下window的,但是不行,你可 ...

  8. nyojb 2359 巴什博弈变形

    http://acm.nyist.me/JudgeOnline/problem.php?id=2359 2359: 巴什博弈? 时间限制: 1 Sec  内存限制: 30 MB提交: 237  解决: ...

  9. linux部署python和加入mysqldb、easy_install

    一.安装easy_install 参考文章: http://www.cnblogs.com/huangjacky/archive/2012/03/28/2421866.html 安装 wget htt ...

  10. es6语法入门let 和 const 命令

    let块级作用域 { let a = 10; var b = 1; } a // ReferenceError: a is not defined. b for循环的计数器,就很合适使用let命令(防 ...