加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

exp之flashback_scn&flashback_time

发布时间:2020-12-15 17:35:01 所属栏目:百科 来源:网络整理
导读:? 以下转自:http://www.voidcn.com/article/p-zahqsvht-co.html?作者:gtlions 这两个参数用于控制导出特定scn和时间戳的时间点的数据,注意这个参数应该和在数据库中使用闪回查询一样有时间限制的(经典的快照过旧:ORA-01555snapshot too old),测试如下

?

以下转自:http://www.voidcn.com/article/p-zahqsvht-co.html?作者:gtlions

这两个参数用于控制导出特定scn和时间戳的时间点的数据,注意这个参数应该和在数据库中使用闪回查询一样有时间限制的(经典的快照过旧:ORA-01555snapshot too old),测试如下:SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 18 11:14:05 2011Copyright (c) 1982,2007,Oracle.? All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - ProductionWith the Partitioning,OLAP,Data Mining and Real Application Testing optionsSQL> desc dbms_flashback;PROCEDURE DISABLEPROCEDURE ENABLE_AT_SYSTEM_CHANGE_NUMBER?Argument Name?? ??? ??? ?Type?? ??? ??? ?In/Out Default??------------------------------ ----------------------- ------ --------?QUERY_SCN?? ??? ??? ?NUMBER?? ??? ??? ?INPROCEDURE ENABLE_AT_TIME?Argument Name?? ??? ??? ?Type?? ??? ??? ?In/Out Default??------------------------------ ----------------------- ------ --------?QUERY_TIME?? ??? ??? ?TIMESTAMP?? ??? ?INFUNCTION GET_SYSTEM_CHANGE_NUMBER RETURNS NUMBERSQL> select dbms_flashback.get_system_change_number from dual;GET_SYSTEM_CHANGE_NUMBER------------------------?? ??? ? 1654903SQL> select count(*) from t4;? COUNT(*)----------?????? 720SQL> delete from t4 where rownum<=100;100 rows deleted.SQL> commit;Commit complete.SQL> select count(1) from t4;? COUNT(1)----------?????? 620SQL>?flashback_scn测试:首先获得当前scn,然后删除表的一些记录,删除之前720,删除之后620;接着测试导出,指定scn为删除之前查询出来的值:[oracle@localhost test]$ exp store1/store1 file=scn.dmp log=scn.log flashback_scn=1654903Export: Release 10.2.0.4.0 - Production on Fri Nov 18 11:16:04 2011.。。。。。。. . exporting table???????????????????????????? T4??????? 720 rows exported可以看到导出的是删除之前的720条记录,接着不指定scn导出:[oracle@localhost test]$ exp store1/store1 file=scn.dmp log=scn.logExport: Release 10.2.0.4.0 - Production on Fri Nov 18 11:16:13 2011Copyright (c) 1982,Oracle.? All rights reserved..。。。。. . exporting table???????????????????????????? T4??????? 620 rows exported这个情况下当然就是最新的620条记录了。time测试,在删除之前看下时间,可以精确到秒,然后指定闪回exp的时间点,说到这里,测试过程中还遇到一个问题,就是转义的问题,最后使用参数文件解决了,其实使用参数文件是个很好的习惯,如果可能尽量使用参数文件,便于重复使用和操作,参数文件如下:[oracle@localhost test]$ cat >parafileflashback_time=to_timestamp('20222228 11:10:00','yyyymmdd hh24:mi:ss')[oracle@localhost test]$ nl parafile????? 1?? ?flashback_time=to_timestamp('20222228 11:10:00','yyyymmdd hh24:mi:ss')使用time时间点导出:[oracle@localhost test]$ exp store1/store1 file=scntime.dmp log=scntime.log parfile=parafileExport: Release 10.2.0.4.0 - Production on Fri Nov 18 11:20:02 2011.。。。. about to export STORE1's tables via Conventional Path .... . exporting table???????????????????????????? T4??????? 720 rows exported一样的也是删除之前的720条记录。exp使用flashback功能还是受到了诸多限制,其中最总要的闪回时间点不是太长,但是在一些特殊场合还是有一些用处,比如用于数据误删除的恢复等等。-The End-

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读