【點擊:】
阿木伯 著
|
|
沒有備份、只有歸檔日志,如何恢復(fù)數(shù)據(jù)文件? |
|
- 系統(tǒng)環(huán)境:
1、操作系統(tǒng):Windows 2000 Server,機器內(nèi)存128M
2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版
3、安裝路徑:C:\ORACLE
- 模擬現(xiàn)象:
可通過重建數(shù)據(jù)文件來恢復(fù),前提是歸檔日志文件保存完整
先將數(shù)據(jù)庫設(shè)置為歸檔模式
SQL*Plus
conn system/manager
--創(chuàng)建實驗表空間
create tablespace test datafile
'c:\test.ora' size 5M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
default storage (initial 128K next 1M pctincrease 0)
/
--創(chuàng)建實驗用戶
drop user test cascade;
create user test identified by test default tablespace test;
grant connect,resource to test;
conn test/test
create table a(a number);
insert into a values(1);
insert into a select * from a; --反復(fù)插入,達到100萬條
commit;
--關(guān)閉數(shù)據(jù)庫
SVRMGR> connect internal
SVRMGR> alter system switch logfile; --強制歸檔
SVRMGR> alter system switch logfile;
SVRMGR> alter system switch logfile;
SVRMGR> shutdown
--操作系統(tǒng)下刪除test.ora文件
--重新啟動數(shù)據(jù)庫
SVRMGR> connect internal
SVRMGR> startup
這時,可以mount上,但無法打開,因為數(shù)據(jù)文件test.ora不存在,
顯示錯誤如下:
ORA-01157: ????/?????? 8 - ??? DBWR ????
ORA-01110: ???? 8: 'C:\TEST.ORA'
SVRMGR> connect internal
SVRMGR> startup mount
SVRMGR> alter database create datafile 'c:\test.ora';
SVRMGR> set autorecovery on
SVRMGR> recover datafile 'c:\test.ora';
SVRMGR> alter database open;
conn test/test
select count(*) from a; --數(shù)據(jù)又恢復(fù)到100萬條
--刪除實驗表空間
conn system/manager
alter tablespace test offline;
drop tablespace test INCLUDING CONTENTS;
drop user test;
--如果是非歸檔模式,也可以運用以上方法,
--前提是:輸入記錄所占空間的大小不超過所有聯(lián)機日志文件的大小
--即:用聯(lián)機日志文件來恢復(fù)
|
【最后更新:】 |
|