数据文件recover状态,没有日志怎么恢复

2025-04-27 23:41:41
推荐回答(2个)
回答1:

可通过重建数据文件来恢复,前提是归档日志文件保存完整先将数据库设置为归档模式SQL*Plusconn system/manager--创建实验表空间create tablespace test datafile'c:\test.ora' size 5MAUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITEDdefault 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/testcreate table a(a number);insert into a values(1);insert into a select * from a;--反复插入,达到100万条commit;--关闭数据库SVRMGR connect internalSVRMGR alter system switch logfile;--强制归档SVRMGR alter system switch logfile;SVRMGR alter system switch logfile;SVRMGR shutdown--操作系统下删除test.ora文件--重新启动数据库SVRMGR connect internalSVRMGR startup这时,可以mount上,但无法打开,因为数据文件test.ora不存在,显示错误如下:ORA-01157: ?/? 8 - ? 8: 'C:\TEST.ORA'SVRMGR connect internalSVRMGR startup mountSVRMGR alter database create datafile 'c:\test.ora';SVRMGR set autorecovery onSVRMGR recover datafile 'c:\test.ora';SVRMGR alter database open;conn test/testselect count(*) from a;--数据又恢复到100万条--删除实验表空间conn system/manageralter tablespace test offline;drop tablespace test INCLUDING CONTENTS;drop user test;--如果是非归档模式,也可以运用以上方法,--前提是:输入记录所占空间的大小不超过所有联机日志文件的大小--即:用联机日志文件来恢复

回答2:

非归档模式联机志没切换覆盖前使用命令先恢复数据文件再数据文件online:
recover datafile '...' ;
alter database datafile '...' online;