【IT168技术文档】
如果你平时没有意识到数据库备份的重要性,然而偏偏此时数据库出现问题,需要恢复。那么你可以尝试利用归档日志进行完全恢复。
系统环境:
1、操作系统:Windows 2000 Server,机器内存128M
2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
3、安装路径:C:\ORACLE
先将数据库设置为归档模式
SQL*Plus
![]()
--创建实验表空间
create tablespace test datafile 'c:\test.ora'
size 5M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
default storage (initial 128K next 1M pctincrease 0)
/
![]()
--创建实验用户
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; --反复插入,达到10万条
commit;
拷贝test.ora为test1.ora文件
insert into a select * from a; --20万条
commit;
关闭数据库
shutdown
删除test.ora文件,把test1.ora拷贝为test.ora。
重新启动数据库。
这时,可以mount上,但无法打开,因为现在使用的数据文件是旧的只有10万条记录,与控制文件中记载的log number不一样。
startup mount
需要recover database,使数据库记录重新恢复到当前的20万条
C:\>svrmgrl
svrmgrl>connect internal
svrmgrl>shutdown
svrmgrl>startup mount
svrmgrl>set autorecovery on
svrmgrl>recover database;
svrmgrl>alter database open;
![]()
conn test/test select count(*) from a; --数据又恢复到20万条
![]()
conn system/manager
--删除实验表空间
alter tablespace test offline;
drop tablespace test INCLUDING CONTENTS;
