Oracle record history using as of timestamp within a range(Oracle 记录历史使用截至时间戳在一个范围内)
问题描述
我最近了解到 oracle 有一个对我非常有用的功能 - 因为设计者/实施者不太关心数据历史 - 如果记录在 oracle 缓存中可用,我可以查询它的历史状态,像这样:
I recently learnt that oracle has a feature which was pretty useful to me - as the designer/implementator didn't care much about data history - I can query the historical state of a record if it's available yet in the oracle cache, like this:
select *
from ( select *
from sometable where some_condition )
as of timestamp sysdate-1
但是现在我需要检查一个范围内的历史数据.无论如何都可以使用缓存吗?
But now I need to check the historical data within a range. Is it possible anyhow, using the cache?
推荐答案
是的,像这样:
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
请注意,您可以返回多远受 UNDO_RETENTION 参数限制,通常是几小时而不是几天.
Note that how far back you can go is limited by the UNDO_RETENTION parameter, and will typically be hours rather than days.
这篇关于Oracle 记录历史使用截至时间戳在一个范围内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Oracle 记录历史使用截至时间戳在一个范围内


- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01