物化视图 - 识别上次刷新

发布于 2024-11-03 09:35:30 字数 289 浏览 3 评论 0原文

我目前访问了一系列视图和具体化视图。物化由第三方维护,该第三方几乎不提供有关物化频率和成功的信息。最近,物化视图无法刷新,我已经发送了许多报告,其中包含不正确/延迟的数据。

目前,我正在查询我打算用来确定事务系统内最新更新何时发生的每个物化,如果尚未刷新,则其余代码不会执行,但是这会浪费很多精力,有时会导致错误的假设(物化视图可能已刷新,但没有进行其他事务 - 因此代码的其余部分不会执行),我更喜欢另一种方法。

有没有办法识别物化视图是否已使用Oracle系统表刷新?如果没有,有谁知道我如何在无需联系第三方的情况下做到这一点?

I presently access a series of views and materialized views. The materialized are maintained by a third party who offers little information regarding the frequency and success of the materialization. Of late the materialized views have failed to refresh and I have sent out numerous reports with incorrect/delayed data contained within.

At present I am querying each materialized I intend to use to establish when the latest update occurred within the transactional system, if it has not been refreshed then the rest of the code does not execute, however this a lot of wasted effort and can sometimes lead to an incorrect assumption (the materialized view may have been refreshed, but there were no additional transactions made - therefore the remainder of the code does not execute) and I would prefer another method.

Is there a way to identify whether a materialized view has been refreshed using an Oracle system table? If not, does anyone have any ideas how I would do this without having to contact the third party?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

度的依靠╰つ 2024-11-10 09:35:30

看起来 doc_180 已经在评论中回答了这个问题,我不确定为什么它没有被添加为答案

SELECT owner, mview_name, last_refresh_date
  FROM all_mviews
 WHERE owner = <<user that owns the materialized view>>
   AND mview_name = <<name of the materialized view>>

如果您有权访问 DBA 表,您可以用 DBA_MVIEWS 替换 ALL_MVIEWS。这将使您能够访问有关每个物化视图何时刷新的信息,而不仅仅是您有权访问的物化视图的子集。当然,在这种情况下,这可能不是特别重要的区别。

It looks like doc_180 already answered this in the comments, I'm not sure why it didn't get added as the answer

SELECT owner, mview_name, last_refresh_date
  FROM all_mviews
 WHERE owner = <<user that owns the materialized view>>
   AND mview_name = <<name of the materialized view>>

If you have access to the DBA tables, you could substitute DBA_MVIEWS for ALL_MVIEWS. That would allow you to get access to information about when every materialized view was refreshed rather than just the subset of materialized views that you have access to. Of course, that's probably not a difference that is particularly important in this case.

梦途 2024-11-10 09:35:30

不幸的是,oracle 默认日期格式是 YYYY-MM-DD。如果你需要时间
只需使用这样的东西:

SELECT owner, mview_name, to_char(LAST_REFRESH_DATE, 'yyyy-mm-dd hh24:mi:ss') last_refresh_date
FROM all_mviews
WHERE owner = 'FOO'
AND mview_name = 'MV_BAR';

Unfortunately oracles default date format is YYYY-MM-DD. If you need the time
just use something like this:

SELECT owner, mview_name, to_char(LAST_REFRESH_DATE, 'yyyy-mm-dd hh24:mi:ss') last_refresh_date
FROM all_mviews
WHERE owner = 'FOO'
AND mview_name = 'MV_BAR';
放手` 2024-11-10 09:35:30

我个人使用 all_snapshots,此信息是 DBA_MVIEWS 或 ALL_MVIEWS 信息的补充

select owner, name, last_refresh, error, status, refresh_mode  
from  all_snapshots 
where owner = 'owner';

Personally i use the all_snapshots, and this information is complementary to the information of the DBA_MVIEWS or ALL_MVIEWS

select owner, name, last_refresh, error, status, refresh_mode  
from  all_snapshots 
where owner = 'owner';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文