系统环境:
1、操作系统:Windows 2000 Server,机器内存128M
2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
3、安装路径:C:\ORACLE
模拟现象:
可通过重建数据文件来恢复,前提是归档日志文件保存完整
先将数据库设置为归档模式
SQL*Plus
conn system/manager
--创建实验表空间
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; --反复插入,达到100万条
commit;
--关闭数据库
SVRMGR> connect internal
SVRMGR> alter system switch logfile; --强制归档
SVRMGR> alter system switch logfile;
SVRMGR> alter system switch logfile;
SVRMGR> shutdown
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; --数据又恢复到100万条
--删除实验表空间
conn system/manager
alter tablespace test offline;
drop tablespace test INCLUDING CONTENTS;
drop user test;