简体   繁体   English

Oracle:加载日期时间

[英]Oracle : Date time of load

I need to extract some data from an Oracle table that was loaded on a particular day.我需要从特定日期加载的 Oracle 表中提取一些数据。 Is there a way to do that?有没有办法做到这一点? The rows do not have any datetimestamp entry这些行没有任何日期时间戳条目

Found it - ORA_ROWSCN.找到了 - ORA_ROWSCN。 Have to figure out how to convert it to a date (SCN_TO_TIMESTAMP is not working)必须弄清楚如何将其转换为日期(SCN_TO_TIMESTAMP 不起作用)

In general, no.一般来说,没有。 You'd need a date column in the table.您需要表中的date列。

If the load was recent, you could try如果负载是最近的,您可以尝试

select scn_to_timestamp( ora_rowscn ), t.*
  from table t

However, there are several problems with this然而,这有几个问题

  • Oracle only knows how to convert recent SCN's to timestamps (on the order of a few days). Oracle 只知道如何将最近的 SCN 转换为时间戳(大约几天)。 You probably would need to create a new function that called scn_to_timestamp and handled the exception if the SCN can't be converted to a timestamp.如果 SCN 无法转换为时间戳,您可能需要创建一个名为scn_to_timestamp的新函数并处理异常。
  • The conversion of an SCN to a timestamp is approximate (should be within a minute)一个 SCN 到时间戳的转换是近似的(应该在一分钟内)
  • Unless the table was built with rowdependencies (which is not the default), the SCN is stored at the block level not at the row level.除非表是使用行rowdependencies (这不是默认值),否则 SCN 存储在块级别而不是行级别。 So if your load changed one row in the block, all the rows in the block would have the same updated SCN.因此,如果您的负载更改了块中的一行,则块中的所有行都将具有相同的更新 SCN。 If you can tolerate picking up some rows that were loaded earlier and/or you know that your load only writes to new blocks, this may be less of an issue.如果您可以容忍选择一些较早加载的行和/或您知道您的加载只写入新块,那么这可能不是一个问题。

Beyond that, you'd be looking at things like whether flashback logs were enabled or some other mechanism was in place to track data versioning.除此之外,您还需要查看是否启用了闪回日志或是否采用了其他一些机制来跟踪数据版本控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM