案例4:
--恢复表空间(open状态)
1)测试环境
07:47:00 SQL> insert into emp1 select * from emp where rownum <3;
2 rows created.
07:47:14 SQL> commit;
Commit complete.
07:47:17 SQL> select * from emp1;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
07:47:20 SQL> conn /as sysdba
Connected.
07:47:23 SQL>
[oracle@work ~]$ rm /u01/app/oracle/oradata/prod/users01.dbf
本栏目更多精彩内容:http://www.bianceng.cn/database/Oracle/
07:47:23 SQL> alter system flush buffer_cache;
System altered.
07:47:41 SQL> conn scott/tiger
Connected.
07:47:44 SQL>
07:47:44 SQL> select * from emp1;
select * from emp1
*
ERROR at line 1:
ORA-01116: error in opening database file 2
ORA-01110: data file 2: '/u01/app/oracle/oradata/prod/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
07:47:48 SQL>
2)恢复表空间
RMAN> run {
2> sql'alter database datafile 2 offline';
3> restore tablespace users;
4> recover tablespace users;
5> sql 'alter database datafile 2 online';
6> }
3)验证
07:47:48 SQL> select * from emp1;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
07:50:31 SQL>