Zso*_*kai 3 sql oracle caching timestamp range
我最近了解到oracle有一个对我来说非常有用的功能 - 因为设计人员/实现者并不关心数据历史 - 我可以在oracle缓存中查询记录的历史状态,如下所示:
select *
from ( select *
from sometable where some_condition )
as of timestamp sysdate-1
Run Code Online (Sandbox Code Playgroud)
但现在我需要检查范围内的历史数据.无论如何,使用缓存是否可能?
是的,像这样:
SQL> select sal from emp where empno=7369;
SAL
----------
5800
SQL> update emp set sal = sal+100 where empno=7369;
1 row updated.
SQL> commit;
Commit complete.
SQL> update emp set sal = sal-100 where empno=7369;
1 row updated.
SQL> commit;
Commit complete.
SQL> select empno, sal, versions_starttime,versions_xid
2 from emp
3 versions between timestamp sysdate-1 and sysdate
4 where empno=7369;
EMPNO SAL VERSIONS_STARTTIME VERSIONS_XID
---------- ---------- --------------------------------------------------------------------------- --
7369 5900 11-DEC-08 16.05.32 0014001300002A74
7369 5800 11-DEC-08 16.03.32 000D002200012EB1
7369 5800
Run Code Online (Sandbox Code Playgroud)
请注意,你可以走多远的地方受到UNDO_RETENTION参数的限制,通常是几小时而不是几天.
归档时间: |
|
查看次数: |
27916 次 |
最近记录: |