ITPub博客

首页 > 数据库 > Oracle > truncate表后的恢复

truncate表后的恢复

原创 Oracle 作者:q418441117 时间:2016-12-13 16:46:14 0 删除 编辑
直接恢复ASM文件:
create tablespace test DATAFILE  size 100M autoextend on maxsize 200M;
create user xhm identified by xhm default tablespace test;
grant connect,resource,dba to xhm;
conn xhm/xhm
create table testtab as select * from dba_objects;
insert into testtab select * from testtab;
alter tablespace test add datafile size 10M autoextend on  maxsize 200M;
SQL> select count(*) from testtab;


  COUNT(*)
----------
   2687744




exec fy_recover_data.recover_truncated_table('XHM','TESTTAB',1,'/tmp'); 


SQL> select count(*) from xhm.testtab$$;


  COUNT(*)
----------
   2687744
   
   insert into xhm.testtab select * from xhm.testtab$$;


收尾:
drop tablespace FY_REC_DATA including contents and datafiles;
drop tablespace FY_RST_DATA including contents and datafiles;








CP文件出来后的恢复:
create table xhm.b as select * from dba_objects;
insert into xhm.b select * from xhm.b where rownum<10000;
alter tablespace test add datafile size 10M autoextend on  maxsize 200M;
SQL> select count(*) from xhm.b;


  COUNT(*)
----------
    153994
   
truncate table xhm.b;


ASMCMD> cp TEST.279.930514719 /tmp/asm1
copying +data/dbtest/datafile/TEST.279.930514719 -> /tmp/asm1
ASMCMD> cp TEST.320.930515319 /tmp/asm2
copying +data/dbtest/datafile/TEST.320.930515319 -> /tmp/asm2


create table xhm.c as select * from dba_objects;




exec fy_recover_data.recover_truncated_table('XHM','B',1,'/tmp'); 
--如果数据被覆盖了,会缺少数据,需要使用cp出来的数据文件


select owner,segment_name,segment_type,tablespace_name from dba_segments where segment_name='B';


exec fy_recover_data.recover_truncated_table('XHM','B',1,'/tmp','/tmp/asm1;/tmp/asm2;');  



收尾:
drop tablespace FY_REC_DATA including contents and datafiles;
drop tablespace FY_RST_DATA including contents and datafiles;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26655292/viewspace-2130421/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-09-11

  • 博文量
    203
  • 访问量
    471900