在论坛看到一个帖子,说是renamedatafile报错了,第一感觉他的语法有问题,也很少用这个命令,就google了一下,发现语法没有问题,可能他的操作顺序有问题。因为rename的时候数据文件必须是offline的,或者数据库是mount状态。
在仔细想了想,以前也整理过一篇rename的文章,不过那篇blog的标题是移动数据文件,和今天的这篇的唯一区别就是在Rename的同时还改了下路径。还有就是这篇是英文的,就当练习一下英语吧。
Oracle移动数据文件的操作方法
http://blog.csdn.net/tianlesoftware/archive/2009/11/30/4899172.aspx
以下内容引自网络:
Datafilescanbemovedorrenamedusingoneoftwomethods:alterdatabaseoraltertablespace.
ThemaindifferencebetweenthemisthataltertablespaceonlyappliestodatafilesthatdonotcontaintheSYSTEMtablespace,activerollbacksegments,ortemporarysegments,buttheprocedurecanbeperformedwhiletheinstanceisstillrunning.Thealterdatabasemethodworksforanydatafile,buttheinstancemustbeshutdown.
1.Thealterdatabasemethod:
1.Shutdowntheinstance.
2.Renameand/ormovethedatafileusingoperatingsystemcommands.
3.Mountthedatabaseandusealterdatabasetorenamethefilewithinthedatabase.Afullyqualifiedfilenameisrequiredinthesyntaxofyouroperatingsystem.Forexampletorenameafilecalled'data01.dbf'to'data04.dbf'andmoveittoanewlocationatthesametime(atthispointintheexampletheinstancehasbeenshutdown)and;
4.Starttheinstance.
SVRMGR>connectsys/oracleassysdba;
SVRMGR>startupmountU1;
SVRMGR>alterdatabaserenamefile'/u01/oracle/U1/data01.dbf'TO'/u02/oracle/U1/data04.dbf';
SVRMGR>alterdatabaseopen;
Noticethesinglequotesaroundthefullyqualifiedfilenamesandremember,thefilesmustexistatthesourceanddestinationpaths.Theinstanceisnowopenusingthenewlocationandnameforthedatafile.
2.Thealtertablespacemethod:
Thismethodhastheadvantagethatitdoesn'trequireshuttingdowntheinstance,butitonlyworkswithnon-SYSTEMtablespaces.Further,itcan'tbeusedfortablespacesthatcontainactiverollbacksegmentsortemporarysegments.
1.Takethetablespaceoffline.
2.Renameand/ormovethedatafileusingoperatingsystemcommands.
3.Usethealtertablespacecommandtorenamethefileinthedatabase.
4.Bringthetablespacebackonline.
SVRMGR>connectsys/oracleassysdba
SVRMGR>altertablespaceapp_dataoffline;
SVRMGR>altertablespaceapp_daterenamedatafile'/u01/oracle/U1/data01.dbf'TO'/u02/oracle/U1/data04.dbf';
SVRMGR>altertablespaceapp_dataonline;
Thetablespacewillbebackonlineusingthenewnameand/orlocationofthedatafile.
BothofthesemethodologiescanbeusedwithinOracleEnterpriseManageralso.