Oracle 11g闪回flashback

查询的语法:

select  …    as of scn | timestamp 

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as hr@JIAGULUN


SQL> select * from student;
        ID NAME                    AGE
----------- -------------------- -----------
          1 zhangsan                21
          2 lisi                          22
          3 wangwu                  23


SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 17:58:58


SQL>
SQL> update student s set s.name='mazi' where s.id = 1;
1 row updated


SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 18:02:56


SQL> delete from student s where s.name = 'lisi';
1 row deleted


SQL> select * from student;
        ID NAME                    AGE
----------- -------------------- -----------
          1 mazi                      21
          3 wangwu                  23


SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 18:04:00


SQL> delete from student;
2 rows deleted


SQL> select * from student;
        ID NAME                    AGE
----------- -------------------- -----------


SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 18:04:26


SQL> select * from student as of scn 3099731;
        ID NAME                    AGE
----------- -------------------- -----------
          1 zhangsan                21
          2 lisi                          22
          3 wangwu                  23
 
SQL> select * from student;
        ID NAME                    AGE
----------- -------------------- -----------


SQL> commit;
Commit complete


SQL> insert into student values(1,'zhangsan',23);
1 row inserted


SQL> commit;
Commit complete


SQL>
SQL>  select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 19:36:30


SQL>
SQL> delete from student;
1 row deleted


SQL> commit;
Commit complete


SQL>  select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 19:36:51


SQL> select * from student as of timestamp to_date('20150124 19:36:30','yyyymmdd hh24:mi:ss');
        ID NAME                    AGE
----------- -------------------- -----------
          1 zhangsan                23


SQL> select * from student as of timestamp to_date('20150124 18:04:26','yyyymmdd hh24:mi:ss');
        ID NAME                    AGE
----------- -------------------- -----------
          1 zhangsan                21
          2 lisi                          22
          3 wangwu                  23


SQL> 

oracle10g的闪回版本查询:
      对于9i的闪回查询进行增强,Oracle10g提供了闪回版本

查询,因为9i的闪回查询仅仅能够得到过去某个时间点上的

数据,但是无法反映出一段时间内数据表中数据的变化,

10g的闪回版本查询可以对时间段内数据表的不同版本进行

查询。

闪回版本查询的语法:

select  …  from  …  versions  between

其中,select后面可以选择伪列,来获得事务的开始、结

束时间、SCN号、ID号等。

SQL>  select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YYYYMMDDHH24:
------------------------------
20150124 19:40:11

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/647f086b6eb914738c7dda51df50b04b.html