表空间备份与恢复主要针对于大型数据库中,某个表空间数据变化非常大,增长速度非常快的情况。表空间的备份实现脚本: run { allocate channel d1 type disk. backup tablespace "TEST","USERS" format ’d:\backup\tb_%d_%s_%p_%t’. release channel d1. }
恢复时,如果用户是要恢复被删除的表空间中的表或视图,或者是使用者用0drop tablespace正常命令删除了表空间,此时控制文件中记录的数据库结构也跟着做了改变,此时只能用不完全恢复,让数据库恢复到以前的一个时间点或SCN。先恢复控制文件,再恢复表空间。 www.zxbc.cn 自学编程网 Shutdown abort. Startup nomount. run { Allocate channel d1 type disk. Restore controlfile from ‘d:\backup\CTL_TEST_0_1_6555’. Release channel d1 . Alter database open. //要为打开状态
set until time "TO_DATE(’08/08/2007 10:50:00’,’MM/DD/YYYY HH24:MI:SS’)". sql ’alter tablespace TEST, USERS offline immediate’. allocate channel d1 type disk. restore tablespace TEST, USERS. recover tablespace TEST, USERS. release channel d1. sql ’alter tablespace TEST, USERS online’. }
注意:After you perform TSPITR on a tablespace, you cannot use backups of that tablespace from before the TSPITR was completed and the tablespace put back on line. If you start using the recovered tablespaces without taking a backup, you are running your database without a usable backup of those tablespaces. For this example, the users and tools tablespaces must be backed up, as follows: RMAN> BACKUP TABLESPACE users, tools. You can then safely bring the tablespaces online, as follows: RMAN> SQL "ALTER TABLESPACE users, tools ONLINE". Your recovered tablespaces are now ready for use.