7步,讓你清楚“如何修改Oracle數(shù)據(jù)文件目錄和數(shù)據(jù)文件名”!
文章來源掌數(shù)科技微信公眾號:Hello_Dataknown
本篇內(nèi)容適用于:
當表空間中的數(shù)據(jù)文件放錯了位置,并且名字不符合要求,想要更改數(shù)據(jù)文件路徑和數(shù)據(jù)文件名的場景。
前提條件:
1.打開了數(shù)據(jù)庫的歸檔模式
2.必須在業(yè)務跑完,數(shù)據(jù)庫沒有外來鏈接時,對數(shù)據(jù)沒有修改時才能進行
例如:原來數(shù)據(jù)文件: /oracle/dsg.dbf
改為:
/oracle/app/oracle/oradata/gao/shine.dbf
接下來就是具體的操作步驟,7步足矣:
Step1:
查看數(shù)據(jù)文件路徑名字和文件號,
把文件號記下來。
SQL> select file_name,file_id from dba_data_files;
Step2:使用rman copy 來把dsg.dbf拷貝一份到想放到的路徑下,并改名字。
rman target /
RMAN>copydatafile 6 to '/oracle/app/oracle/oradata/gao/shine.dbf';
Step3:
在sqlplus中讓6號文件下線。
SQL> alter database datafile 6 offline;
Step4:
在sqlplus中重定義該數(shù)據(jù)文件的名字和目錄
alter database rename file '/oracle/dsg.dbf' to '/oracle/app/oracle/oradata/gao/shine.dbf';
Step5:
在rman中恢復該數(shù)據(jù)文件。
rman target /
recover datafile 6;
Step6:
在sqlplus中讓該數(shù)據(jù)文件online。
SQL>alter database datafile 6 online;
Step7:
查看數(shù)據(jù)文件路徑名字和文件編號。
SQL> select name,file# from v$datafile;
下一篇:DBA日記之Oracle初始化參數(shù)說明(oracle 11g)