gpt4 book ai didi

sql - 如何在Oracle中使用Timestamp_to_scn和Scn_to_timestamp?

转载 作者:行者123 更新时间:2023-12-01 19:47:53 32 4
gpt4 key购买 nike

我的查询结果是这样的:

select cast(to_date(a.start_time,'mm/dd/yyyy hh:mi:ss pm') as timestamp) date_of_call,
ora_rowscn from calling_table a where rownum <= 10;

DATE_OF_CALLING ORA_ROWSCN

26-JUL-13 12.29.28.000000000 PM 8347567733892
26-JUL-13 12.29.35.000000000 PM 8347567733892
26-JUL-13 12.29.35.000000000 PM 8347567733892
26-JUL-13 12.29.38.000000000 PM 8347567733892
26-JUL-13 12.29.44.000000000 PM 8347567733892
26-JUL-13 12.29.47.000000000 PM 8347567733892
26-JUL-13 12.29.48.000000000 PM 8347567733892
26-JUL-13 12.29.48.000000000 PM 8347567733892
26-JUL-13 12.29.48.000000000 PM 8347567733892
26-JUL-13 12.29.56.000000000 PM 8347567733892

但是当我尝试使用函数timestamp_to_scn将此时间戳转换为scn时,我收到以下错误:

ORA-08180: 没有根据指定时间找到快照ORA-06512: 在“SYS.TIMESTAMP_TO_SCN”,第 1 行08180. 00000 - “没有根据指定时间找到快照”*原因:无法将时间与映射表中的 SCN 相匹配。*行动:尝试使用更长的时间。

当我在 ora_rowscn 上使用 scn_to_timestamp 将该列转换为时间戳时,出现以下错误:

ORA-08181: 指定的编号不是有效的系统更改编号ORA-06512: 在“SYS.SCN_TO_TIMESTAMP”,第 1 行08181. 00000 - “指定的号码不是有效的系统更改号码”*原因:提供的 scn 超出了有效 scn 的范围。*操作:使用有效的 scn。

我做错了什么?

最佳答案

你试图把目光看得太远。您只能在系统维护的重做/闪回窗口中与 SCN 进行转换。一旦更改过期,映射就会丢失。

这已解释in the documentation :

The association between an SCN and a timestamp when the SCN is generated is remembered by the database for a limited period of time. This period is the maximum of the auto-tuned undo retention period, if the database runs in the Automatic Undo Management mode, and the retention times of all flashback archives in the database, but no less than 120 hours. The time for the association to become obsolete elapses only when the database is open. An error is returned if the SCN specified for the argument to SCN_TO_TIMESTAMP is too old.

请记住,这些是 Oracle 内部机制的一部分,因此对我们的用处有限;当然,它们对于闪回查询很有用 - 再次在同一窗口内。

关于sql - 如何在Oracle中使用Timestamp_to_scn和Scn_to_timestamp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22681705/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com