[Experiment-video process] oracle hot backup-single tablespace-backup and recovery operation demonstration
[Experiment-video process] oracle hot backup-single tablespace-backup and recovery operation demonstration
Restore a tablespace
1. Create a tablespace
drop tablespace test_backup including contents and datafiles;CREATE TABLESPACE test_backup DATAFILE '/u01/app/oracle/oradata/orcl/test_back.dbf' SIZE 10M autoextend on;
2. Write test data and create a test table
drop table test_backup purge;CREATE TABLE test_backup( aa NUMBER, bb VARCHAR2(10)) TABLESPACE test_backup;
3. Insert test data, the first one.
insert into test_backup values (1,'test_back1'); commit;
4. Set the backup mode for the database
SQL> ALTER TABLESPACE test_backup BEGIN BACKUP;Tablespace altered.
5. copy the data file to the backup file.
host cp /u01/app/oracle/oradata/orcl/test_back.dbf /home/backup/xuejiayue/
6. End backup mode
SQL> ALTER TABLESPACE test_backup END BACKUP;Tablespace altered.
7. Switch logs
SQL> ALTER SYSTEM SWITCH LOGFILE;System altered.
8. Insert the data again and insert the second data (the backup is completed now ).
SQL> insert into test_backup values (2,'test_back2');1 row created.SQL> commit;Commit complete.
9. Simulate faults and delete database files
host rm -rf /u01/app/oracle/oradata/orcl/test_back.dbf
10. Restart the database
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.startup
11. Data File error should be reported in the test data table.
SQL> select * from test_backup;select * from test_backup *ERROR at line 1:ORA-00376: file 6 cannot be read at this timeORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/test_back.dbf'
12. Recover a single tablespace database file in the database.
SQL> ALTER DATABASE DATAFILE 6 OFFLINE DROP 2 ;Database altered.SQL> host cp /home/backup/xuejiayue/test_back.dbf /u01/app/oracle/oradata/orcl/test_back.dbf SQL> RECOVER DATAFILE 6Media recovery complete.SQL> ALTER DATABASE DATAFILE 6 ONLINE;Database altered.
12. Test Data after recovery is completed.
SQL> select * from test_backup; AA BB---------- ---------- 1 test_back1 2 test_back2
The result is: both data files are in !!!
Video address
Http://v.youku.com/v_show/id_XMTM2MzI0NjcyMA==.html