Oracle-Materialized View,这个MV可以快速刷新吗?

发布于 2024-11-28 01:36:33 字数 715 浏览 2 评论 0原文

我有一个看起来有点像下面的物化视图,我想知道是否有办法让这个物化视图“快速”刷新?基本上,我要问以下问题:

  1. 物化视图可以包含 Oracle 函数(例如 COALESCE、NVL、NVL2 等)并且仍然可以快速刷新

  2. 物化视图可以包含我所做的功能并且仍然可以快速刷新吗?

  3. 物化视图可以包含与派生表的联接并且仍然可以快速刷新吗?

我检查了关于此的 Oracle 文档 ,并且它没有列出这些限制,但是在我自己的系统上测试下面的情况后,我不相信这是可能的。

甲骨文版本:10g

SELECT COALESCE (col1, col2),
       myOracleFunction(col3, col4)
  FROM tableA a 
       LEFT OUTER JOIN
       (SELECT   id, MAX (sample_key) prim_sam_key
            FROM table_sample
        GROUP BY id
          HAVING COUNT (1) = 1) b ON a.id = b.id;

I have a materialized view that looks somewhat like the following and I'm wondering if there is anyway to have this materialized view 'fast' refreshable? Basically, I'm asking the following:

  1. Can a materialized view contain oracle functions such as COALESCE, NVL, NVL2, etc and still be fast refreshable

  2. Can a materialized view contain functions that I have made and still be fast refreshable.

  3. Can a materialized view contain joins to derived tables and still be fast refreshable?

I checked the Oracle documentation about this, and it did not list these restrictions, however after testing the case below on my own system, I don't believe it is possible.

Oracle version: 10g

SELECT COALESCE (col1, col2),
       myOracleFunction(col3, col4)
  FROM tableA a 
       LEFT OUTER JOIN
       (SELECT   id, MAX (sample_key) prim_sam_key
            FROM table_sample
        GROUP BY id
          HAVING COUNT (1) = 1) b ON a.id = b.id;

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

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

发布评论

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

评论(1

撩人痒 2024-12-05 01:36:33

您提供的链接中的要求你缺少:

  • 必须指定 COUNT(*)。
  • SELECT 列表必须包含所有 GROUP BY 列。

此外,以下要求表明,对于您的查询,只有在 table_sample 已更新但 tableA 尚未更新时才可能进行快速刷新:

  • 具有外部连接的物化聚合视图可快速刷新
    常规DML和直接加载后,仅提供外表
    已被修改。此外,连接上必须存在唯一约束
    内连接表的列。如果存在外连接,则所有
    连接必须通过 AND 连接并且必须使用等号 (=)
    运算符。

最后,当询问物化视图时,最好准确地说明您创建了哪些物化视图日志。

Requirements from the link you provided that you're missing:

  • COUNT(*) must be specified.
  • The SELECT list must contain all GROUP BY columns.

Also, the following requirement indicates that, for your query, a fast refresh will only be possible if table_sample has been updated, but tableA has not:

  • Materialized aggregate views with outer joins are fast refreshable
    after conventional DML and direct loads, provided only the outer table
    has been modified. Also, unique constraints must exist on the join
    columns of the inner join table. If there are outer joins, all the
    joins must be connected by ANDs and must use the equality (=)
    operator.

Finally, when asking about materialized views, it is always a good idea to state exactly what materialized view logs you have created.

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