孙俊强

坚持每天学习
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

Posted on 2011-11-25 09:29  孙俊强  阅读(222)  评论(0编辑  收藏  举报

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>