zoukankan      html  css  js  c++  java
  • flashback query


    flashback query 是基于 undo 表空间的,对于10g,11g的数据库是不需要额外设置的。


    对于 undo_retention设置比较大,同时又设置了 retention guarantee 的数据库是大大的有用。



    下面做一些简单操作演示下。


    --创建临时表
    create table tmp_pyb_20160418
    as
    select *
    from dba_objects do
    where 1=1
    and rownum < 1000
    ;


    --查看临时表的记录
    select *
    from tmp_pyb_20160418
    where 1=1
    ;


    --查看临时表的记录
    select distinct owner
    from tmp_pyb_20160418
    where 1=1
    ;

    OWNER
    PUBLIC
    OUTLN
    SYS


    --获取删除前的SCN
    select dbms_flashback.get_system_change_number
    from dual;

    10806245540173


    --删除临时表的一些记录
    delete from tmp_pyb_20160418 tp
    where 1=1
    and tp.owner='SYS'
    ;
    commit;


    --临时表中owner='SYS'的记录都已经被删除了
    select *
    from  tmp_pyb_20160418 tp
    where 1=1
      and tp.owner='SYS'
    ;


    --使用 as of timestamp 或者 as of scn 查询删除前的数据
    select *
    from  tmp_pyb_20160418 as of timestamp to_timestamp('2016-04-18 10:47:00','yyyy-mm-dd hh24:mi:ss') tp
    where 1=1
      and tp.owner='SYS'
    ;


    select *
    from  tmp_pyb_20160418 as of scn 10806245540173 tp
    where 1=1
      and tp.owner='SYS'
    ;






  • 相关阅读:
    Vim插件:Unite新手指导(译)
    Java并发编程实战3章
    Centos6.*下安装gcc-4.8.2
    iostat详解
    国内速度比较快的NTP Server
    ssh免密登录配置
    解决卸载移动硬盘问题:umount:/usb1/:device is busy
    Centos查看系统安装日期
    主机IP规划__rsync__inotify
    熟悉OSI七层模型
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9793177.html
Copyright © 2011-2022 走看看