查询oracle下没有时间戳的表中的记录插入时间

近日线上系统出现一个表中数据重复的问题,但是根据业务流程来讲不可能出现该种情况,只可惜该表中没有加入时间戳,所以问题变的不好查。

所以网上查了相关资料,发现可以用以下的语句查询:

select t.seq_id,t.hall_id,to_char(scn_to_timestamp(ORA_ROWSCN),'yyyy-mm-dd hh24:mi:ss:ff8') insert_time from dim_geog_a t;

查询结构如下图所示:

但是此语句去查询的是偶该表中相关记录不能超过5天否则会报 不是有效的系统更改号的错误。

说明如下:

Cause

This is expected behavior as the SCN must be no older than 5 days as part of the current flashback database
features.

Currently, the flashback query feature keeps track of times up to a
maximum of 5 days. This period reflects server uptime, not wall-clock
time. You must record the SCN yourself at the time of interest, such as
before doing a DELETE.

扫描二维码关注公众号,回复: 7652074 查看本文章

我们可以通过如下语句查询每条记录的rowscn。

SELECT --deptno,
        --dname,loc,
        dbms_rowid.rowid_block_number(ROWID) blockno,
        ora_rowscn
FROM dim_geog_a;

select * from dim_geog_a as of scn 74757285358;

网上相关资料说能够建表时加参数知晓行级的scn信息,但是我查询不可行()即统一时间内插入的是一样的,只有间隔一点时间才不一样。

默认情况下,每行记录的ORA_ROWSCN是基于Block的,这样是不准确的,除非在建表的时候执行开启行级跟踪(create table … rowdependencies),这样就会是在行级记录scn。

待得到答案后再更新。

猜你喜欢

转载自blog.csdn.net/zidielang/article/details/56852114
今日推荐