Chinaunix首页 | 论坛 | 博客
  • 博客访问: 229533
  • 博文数量: 57
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 674
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-30 22:48
个人简介

2014,换个角度,希望接下来的事情值得期待。

文章分类

全部博文(57)

文章存档

2015年(1)

2014年(55)

2013年(1)

我的朋友

分类: Oracle

2014-02-07 21:45:02

Flashback Query 可以看到一个点的状态,Flashback version Query可以看到某个时间段内的记录是如何发生变化的。10g以后,使用ORA_ROWSCN来跟踪记录的变化情况。
SQL> create table testquery(name varchar2(30));
 
Table created
 
SQL> insert into testquery values('jerry');
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> select * from testquery;
 
NAME
------------------------------
jerry


SQL> insert into testquery values('tom');
 
1 row inserted
 
SQL> commit;
 
Commit complete


SQL> alter system switch logfile;
 
System altered
 
SQL> select ora_rowscn,name from testquery;
 
ORA_ROWSCN NAME
---------- ------------------------------
   9773673 jerry
   9773673 tom
 
SQL> insert into testquery values('you');
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> select ora_rowscn,name from testquery;
 
ORA_ROWSCN NAME
---------- ------------------------------
   9773710 you
   9773710 jerry
   9773710 tom
   
 SQL> Select versions_xid,
  2         versions_startscn,
  3         versions_endscn,
  4         DECODE(versions_operation,
  5                'I',
  6                'Insert',
  7                'U',
  8                'Update',
  9                'D',
 10                'Delete',
 11                'Original') "Operation",
 12         name
 13    from testquery versions between scn minvalue and maxvalue
 14  /
 
VERSIONS_XID     VERSIONS_STARTSCN VERSIONS_ENDSCN Operation NAME
---------------- ----------------- --------------- --------- ------------------------------
15000B002C010000           9773710                 Insert    you
1A001B0026010000           9773673                 Insert    tom
18000F002E010000           9773599                 Insert    jerry
190006001F010000           9773594                 Delete    jerry
1300010021010000           9773584         9773594 Insert    jerry
 
5 rows selected  


ORA_ROWSCN记录的最后一次提交的SCN。缺省为数据块级别,即同一数据块中的所有记录,都是同一个ORA_ROWSCN.
块中的任一记录被修改后,此块内的ORA_ROWSCN都会变化。
可以使用rowdependencies,使每行都有一个专用的ORA_ROWSCN
SQL> insert into testpersonalscn values('me');
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> insert into testpersonalscn values('you');
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> select ora_rowscn,name from testpersonalscn;
 
ORA_ROWSCN NAME
---------- ------------------------------
   9774100 me
   9774103 you

阅读(1219) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~