1. <tfoot id='bRkY8'></tfoot>
      <legend id='bRkY8'><style id='bRkY8'><dir id='bRkY8'><q id='bRkY8'></q></dir></style></legend>

        <small id='bRkY8'></small><noframes id='bRkY8'>

          <bdo id='bRkY8'></bdo><ul id='bRkY8'></ul>

      1. <i id='bRkY8'><tr id='bRkY8'><dt id='bRkY8'><q id='bRkY8'><span id='bRkY8'><b id='bRkY8'><form id='bRkY8'><ins id='bRkY8'></ins><ul id='bRkY8'></ul><sub id='bRkY8'></sub></form><legend id='bRkY8'></legend><bdo id='bRkY8'><pre id='bRkY8'><center id='bRkY8'></center></pre></bdo></b><th id='bRkY8'></th></span></q></dt></tr></i><div id='bRkY8'><tfoot id='bRkY8'></tfoot><dl id='bRkY8'><fieldset id='bRkY8'></fieldset></dl></div>
      2. Oracle - 如何使用 FAST REFRESH 和 JOINS 创建物化视图

        时间:2023-09-19
        <legend id='QP1Nx'><style id='QP1Nx'><dir id='QP1Nx'><q id='QP1Nx'></q></dir></style></legend>

            • <tfoot id='QP1Nx'></tfoot>
                <bdo id='QP1Nx'></bdo><ul id='QP1Nx'></ul>
                <i id='QP1Nx'><tr id='QP1Nx'><dt id='QP1Nx'><q id='QP1Nx'><span id='QP1Nx'><b id='QP1Nx'><form id='QP1Nx'><ins id='QP1Nx'></ins><ul id='QP1Nx'></ul><sub id='QP1Nx'></sub></form><legend id='QP1Nx'></legend><bdo id='QP1Nx'><pre id='QP1Nx'><center id='QP1Nx'></center></pre></bdo></b><th id='QP1Nx'></th></span></q></dt></tr></i><div id='QP1Nx'><tfoot id='QP1Nx'></tfoot><dl id='QP1Nx'><fieldset id='QP1Nx'></fieldset></dl></div>

                <small id='QP1Nx'></small><noframes id='QP1Nx'>

                    <tbody id='QP1Nx'></tbody>
                1. 本文介绍了Oracle - 如何使用 FAST REFRESH 和 JOINS 创建物化视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我很确定 Oracle 支持这一点,所以我不知道我做错了什么.此代码有效:

                  So I'm pretty sure Oracle supports this, so I have no idea what I'm doing wrong. This code works:

                  CREATE MATERIALIZED VIEW MV_Test
                    NOLOGGING
                    CACHE
                    BUILD IMMEDIATE 
                    REFRESH FAST ON COMMIT 
                    AS
                      SELECT V.* FROM TPM_PROJECTVERSION V;
                  

                  如果我添加一个 JOIN,它会中断:

                  If I add in a JOIN, it breaks:

                  CREATE MATERIALIZED VIEW MV_Test
                    NOLOGGING
                    CACHE
                    BUILD IMMEDIATE 
                    REFRESH FAST ON COMMIT 
                    AS
                      SELECT V.*, P.* FROM TPM_PROJECTVERSION V
                      INNER JOIN TPM_PROJECT P ON P.PROJECTID = V.PROJECTID
                  

                  现在出现错误:

                  ORA-12054:无法为物化视图设置 ON COMMIT 刷新属性

                  我在 TPM_PROJECT 和 TPM_PROJECTVERSION 上都创建了物化视图日志.TPM_PROJECT 的主键为 PROJECTID,TPM_PROJECTVERSION 的复合主键为 (PROJECTID,VERSIONID).这有什么诀窍?我一直在翻阅 Oracle 手册,但无济于事.谢谢!

                  I've created materialized view logs on both TPM_PROJECT and TPM_PROJECTVERSION. TPM_PROJECT has a primary key of PROJECTID and TPM_PROJECTVERSION has a compound primary key of (PROJECTID,VERSIONID). What's the trick to this? I've been digging through Oracle manuals to no avail. Thanks!

                  推荐答案

                  先从 Oracle 数据库数据仓库指南:

                  仅具有联接的物化视图的快速刷新限制

                  ...

                  • FROM 列表中所有表的 Rowids 必须出现在 SELECT查询列表.

                  这意味着您的语句需要如下所示:

                  This means that your statement will need to look something like this:

                  CREATE MATERIALIZED VIEW MV_Test
                    NOLOGGING
                    CACHE
                    BUILD IMMEDIATE 
                    REFRESH FAST ON COMMIT 
                    AS
                      SELECT V.*, P.*, V.ROWID as V_ROWID, P.ROWID as P_ROWID 
                      FROM TPM_PROJECTVERSION V,
                           TPM_PROJECT P 
                      WHERE P.PROJECTID = V.PROJECTID
                  

                  另一个需要注意的关键方面是,您的物化视图日志必须创建为 with rowid.

                  Another key aspect to note is that your materialized view logs must be created as with rowid.

                  以下是功能测试场景:

                  CREATE TABLE foo(foo NUMBER, CONSTRAINT foo_pk PRIMARY KEY(foo));
                  
                  CREATE MATERIALIZED VIEW LOG ON foo WITH ROWID;
                  
                  CREATE TABLE bar(foo NUMBER, bar NUMBER, CONSTRAINT bar_pk PRIMARY KEY(foo, bar));
                  
                  CREATE MATERIALIZED VIEW LOG ON bar WITH ROWID;
                  
                  CREATE MATERIALIZED VIEW foo_bar
                    NOLOGGING
                    CACHE
                    BUILD IMMEDIATE
                    REFRESH FAST ON COMMIT  AS SELECT foo.foo, 
                                                      bar.bar, 
                                                      foo.ROWID AS foo_rowid, 
                                                      bar.ROWID AS bar_rowid 
                                                 FROM foo, bar
                                                WHERE foo.foo = bar.foo;
                  

                  这篇关于Oracle - 如何使用 FAST REFRESH 和 JOINS 创建物化视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Oracle 连接 URL 中的默认架构 下一篇:使用 SqlAlchemy 和 cx_Oracle 将 Pandas DataFrame 写入 Oracle 数据库时加

                  相关文章

                  <legend id='jsQU8'><style id='jsQU8'><dir id='jsQU8'><q id='jsQU8'></q></dir></style></legend>

                  1. <tfoot id='jsQU8'></tfoot>

                  2. <small id='jsQU8'></small><noframes id='jsQU8'>

                      <i id='jsQU8'><tr id='jsQU8'><dt id='jsQU8'><q id='jsQU8'><span id='jsQU8'><b id='jsQU8'><form id='jsQU8'><ins id='jsQU8'></ins><ul id='jsQU8'></ul><sub id='jsQU8'></sub></form><legend id='jsQU8'></legend><bdo id='jsQU8'><pre id='jsQU8'><center id='jsQU8'></center></pre></bdo></b><th id='jsQU8'></th></span></q></dt></tr></i><div id='jsQU8'><tfoot id='jsQU8'></tfoot><dl id='jsQU8'><fieldset id='jsQU8'></fieldset></dl></div>
                      • <bdo id='jsQU8'></bdo><ul id='jsQU8'></ul>