exp之flashback_scn&flashback_time

这两个参数用于控制导出特定scn和时间戳的时间点的数据,注意这个参数应该和在数据库中使用闪回查询一样有时间限制的(经典的快照过旧:ORA-01555snapshot too old),测试如下:
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 18 11:14:05 2011

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> desc dbms_flashback;
PROCEDURE DISABLE
PROCEDURE ENABLE_AT_SYSTEM_CHANGE_NUMBER
 Argument Name            Type            In/Out Default?
 ------------------------------ ----------------------- ------ --------
 QUERY_SCN            NUMBER            IN
PROCEDURE ENABLE_AT_TIME
 Argument Name            Type            In/Out Default?
 ------------------------------ ----------------------- ------ --------
 QUERY_TIME            TIMESTAMP        IN
FUNCTION GET_SYSTEM_CHANGE_NUMBER RETURNS NUMBER

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
         1654903

SQL> select count(*) from t4;

  COUNT(*)
----------
       720

SQL> delete from t4 where rownum<=100;

100 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(1) from t4;

  COUNT(1)
----------
       620

SQL>
flashback_scn测试:
首先获得当前scn,然后删除表的一些记录,删除之前720,删除之后620;接着测试导出,指定scn为删除之前查询出来的值:
[oracle@localhost test]$ exp store1/store1 file=scn.dmp log=scn.log flashback_scn=1654903

Export: 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.log

Export: Release 10.2.0.4.0 - Production on Fri Nov 18 11:16:13 2011

Copyright (c) 1982, 2007, Oracle.  All rights reserved.
.。。。。
. . exporting table                             T4        620 rows exported
这个情况下当然就是最新的620条记录了。
time测试,在删除之前看下时间,可以精确到秒,然后指定闪回exp的时间点,说到这里,测试过程中还遇到一个问题,就是转义的问题,最后使用参数文件解决了,其实使用参数文件是个很好的习惯,如果可能尽量使用参数文件,便于重复使用和操作,参数文件如下:
[oracle@localhost test]$ cat >parafile
flashback_time=to_timestamp('20111118 11:10:00','yyyymmdd hh24:mi:ss')
[oracle@localhost test]$ nl parafile
     1    flashback_time=to_timestamp('20111118 11:10:00','yyyymmdd hh24:mi:ss')
使用time时间点导出:
[oracle@localhost test]$ exp store1/store1 file=scntime.dmp log=scntime.log parfile=parafile

Export: 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-


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值