资源描述:
《oracle rman 进行表空间基于时间点恢复》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、RMANTSPITR使用rman进行表空间基于时间点的恢复收藏实例说明:(1)先创建2个表空间。createtablespaceuser01datafile'+DG1'size1M;createtablespaceuser02datafile'+DG1'size1M;(2)在每个表空间上各创建一张表。createtablescott.customers(cust_idint,cust_namevarchar2(10))tablespaceuser01;createtablescott.sales(idint,cust_namev
2、archar2(10),sales_amountnumber(8,2))tablespaceuser02;(3)在每个表中插入2条记录,提交。检查当前的时间点,待会表空间user01要恢复到当前时间点。insertintoscott.customersvalues(1,'SOCTT');insertintoscott.customersvalues(2,'SMITH');insertintoscott.salesvalues(1,'SCOTT',8000);insertintoscott.salesvalues(1,'SMITH
3、',10000);COMMIT;ALTERSYSTEMSWITCHLOGFILE;ALTERSYSTEMSWITCHLOGFILE;ALTERSYSTEMSWITCHLOGFILE;date2010年03月11日星期四21:44:52CST(4)truncate表1,往表2中插入2条记录。在表空间1中再创建一个表。truncatetablescott.customers;insertintoscott.salesvalues(3,'SCOTT',6000);insertintoscott.salesvalues(4,'BLAKE
4、',6700);commit;createtablescott.employee(idint,namevarchar2(10))tablespaceuser01;(5)利用rman进行表空间1基于时间点的恢复。--rman部分恢复表空间recovertablespaceuser01untiltime"to_timestamp('2010-03-1121:44:52','yyyy-mm-ddhh24:mi:ss')"auxiliarydestination'/home/oracle/backup';(6)将表空间user01联机,
5、检查表1的数据是否找回来,检查表2的数据是否是4条,检查新创建的表是否已经不存在。altertablespaceuser01online;select*fromscott.customers;CUST_IDCUST_NAME--------------------1SOCTT2SMITHselect*fromscott.sales;IDCUST_NAMESALES_AMOUNT--------------------------------1SCOTT80001SMITH100003SCOTT60004BLAKE6700sele
6、ct*fromdba_tableswhereowner='SCOTT'andtable_name='EMPLOYEE';norowsselected一切如我们所愿,此时,表空间不完全恢复完成。注意:只有自包含的表空间,才能基于单独不完全恢复。所谓自包含,是指该表空间中的对象不依赖于其它表空间中的对象,如该表空间中索引的基本在其它表空间,该表中某些表的lob列放在其它表空间。如在上例中,执行:createindexscott.idx_customersonscott.customers(cust_name)tablespaceus
7、er02;begindbms_tts.transport_set_check('user02',true);end;select*fromtransport_set_violations;会提示:IndexSCOTT.IDX_CUSTOMERSintablespaceUSER02pointstotableSCOTT.CUSTOMERSintablespaceUSER01.begindbms_tts.transport_set_check('USER01,user02',true);end;select*fromtransport
8、_set_violations;不会有任何提示,因为user01/user02表空间作为一个集合,是自包含的。上面这个过程看起来简单,但是数据库在步骤5时,自己做了很多的工作,所有以前人工需要做的它一步也没有少做,具体如下:(1)建立参数文件(2)启动辅助ins