删除数据文件后恢复——小实验

SYS@orcl> create tablespace testspace datafile 'D:\testdatafile' size 10M

SYS@orcl> create table scott.testtable(id varchar2(16)) tablespace testspace;

SYS@orcl> insert into scott.testTable(id) values(1234567);

SYS@orcl> insert into scott.testTable(id) values(123456789);

SYS@orcl> commit;

SYS@orcl> select * from scott.testtable;

ID
----------------
1234567
123456789

SYS@orcl> alter tablespace testspace offline;

删除D:\testdatafile数据文件

SYS@orcl> recover tablespace testspace;
ORA-00283: recovery session canceled due to errors
ORA-01110: data file 7: 'D:\TESTDATAFILE'
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: 'D:\TESTDATAFILE'

SYS@orcl> alter database create datafile 7;

SYS@orcl> recover datafile 7;

SYS@orcl> select * from scott.testtable;
select * from scott.testtable
                    *
ERROR at line 1:
ORA-00376: file 7 cannot be read at this time
ORA-01110: data file 7: 'D:\TESTDATAFILE'

 SYS@orcl> alter tablespace testspace online;

SYS@orcl> select * from scott.testtable;

ID
----------------
1234567
123456789

SYS@orcl>

坚持每天学习
原文地址:https://www.cnblogs.com/jsnewland/p/2262642.html