Welcome 微信登录

首页 / 数据库 / MySQL / 如何去掉Oracle数据文件名中空格

环境:Oracle Linux Server release 6.4 oracle 11.2.0.1.0问题描述与分析:经常会有在建立表空间时,在数据文件命名时中间或结尾处多个空格,该如何将这名字里面的空格去掉呢,下面我们实验如何去掉。改名思路:将表空间offline,系统级rename,数据库级rename,表空间online,检查数据。1. 创建测试表空间sys@ORCL>create tablespace aaa datafile "/11g/app/oracle/oradata/ORCL/aaa bbb.dbf" size 10m;Tablespace created.2. 将表空间offlinesys@ORCL>alter tablespace aaa offline;Tablespace altered.3. 直接修改数据文件名字报错sys@ORCL>alter database rename file "/11g/app/oracle/oradata/ORCL/aaa bbb.dbf" to "/11g/app/oracle/oradata/ORCL/aaabbb.dbf";alter database rename file "/11g/app/oracle/oradata/ORCL/aaa bbb.dbf" to "/11g/app/oracle/oradata/ORCL/aaabbb.dbf"*ERROR at line 1:ORA-01511: error in renaming log/data filesORA-01141: error renaming data file 8 - new file "/11g/app/oracle/oradata/ORCL/aaabbb.dbf" notfoundORA-01110: data file 8: "/11g/app/oracle/oradata/ORCL/aaa bbb.dbf"ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 34. 修改操作系统级数据文件名字[oracle@test ORCL]$ mv aaa bbb.dbf aaabbb.dbf[oracle@test ORCL]$ lsaaabbb.dbf   redo01.log  SYSAUX01.DBF TEST.DBF     wmis01.dbfcontrol01.ctl  redo02.log  SYSTEM01.DBF UNDOTBS01.DBFEXAMPLE01.DBF  redo03.log  temptbs01.dbf  USERS01.DBF5. 修改数据库级数据文件名字
sys@ORCL>alter database rename file "/11g/app/oracle/oradata/ORCL/aaa bbb.dbf" to "/11g/app/oracle/oradata/ORCL/aaabbb.dbf";Database altered.6. 将数据文件onlinesys@ORCL>alter tablespace aaa online;Tablespace altered.sys@ORCL>select name from v$datafile where file#=8;NAME----------------------------------------------------------------------------------------------------/11g/app/oracle/oradata/ORCL/aaabbb.dbf 
 总结:此次测试主要是在系统级改名字与在数据库级改名字,谁在前谁在后问题。上面我举了错误顺序的例子和报错。生产库改前最好还是弄个备份,DBA的救命稻草,有备无患! 更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址