备份user表空间
SQL> alter tablespace users beginbackup;
Tablespace altered.
SQL> !cp/u01/tiger/oradata/orcl2/users01.dbf /bk
SQL> alter tablespace users end backup;
Tablespace altered
做交易然后破坏user表空间
SQL> !cp /etc/passwd/u01/tiger/oradata/orcl2/users01.dbf
SQL> alter system switch logfile;
System altered.
SQL> select * from emp;
select * from emp
*
ERROR at line 1:
ORA-00376: file 4 cannot be readat this time
ORA-01110: data file 4:'/u01/tiger/oradata/orcl2/users01.dbf'
SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- --------------------------- ---------- ---------
4 OFFLINE OFFLINE FILE NOT FOUND 0
SQL> !cp /bk/users01.dbf/u01/tiger/oradata/orcl2/users01.dbf
SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- --------------------------- ---------- ---------
4 OFFLINE OFFLINE 563482 06-SEP-12
SQL> select * from v$recovery_log;
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
------------------------------------------------------------------------------------------------------------------------
1 10 06-SEP-12
/u01/tiger/flash_recovery_area/ORCL2/archivelog/2012_09_06/o1_mf_1_10_84jpo5bw_.arc
1 11 06-SEP-12
/u01/tiger/flash_recovery_area/ORCL2/archivelog/2012_09_06/o1_mf_1_11_84jpoctx_.arc
SQL> alter tablespace users online;
alter tablespace users online
*
ERROR at line 1:
ORA-01113: file 4 needs mediarecovery
ORA-01110: data file 4:'/u01/tiger/oradata/orcl2/users01.dbf'
SQL> recoverdatafile 4;
Media recovery complete.
SQL> alter tablespace users online;