• [Oracle维护工程师手记]两表结合的MVIEW的告诉刷新


    对两表结合查询建立MVIEW,进行MVIEW的的高速刷新失败,如何处理?

    例如:

    SQL> drop user u1 cascade;

    User dropped.

    SQL> grant dba to u1 identified by u1;

    Grant succeeded.

    SQL> conn u1/u1
    Connected.

    SQL> create table TAB001 (col1 integer primary key, col2 integer, val3 integer);

    Table created.

    SQL> create materialized view log on tab001;

    Materialized view log created.

    SQL> create table TAB002 (col1 integer primary key, col2 integer, val3 integer);

    Table created.

    SQL>
    SQL> create materialized view log on tab002;


    SQL> create materialized view mv001
    as
    SELECT t1.col1 as t1c0l1, t1.col2 as t1col2, t2.col1 as t2col1, t2.col2 as t2col2 , t1.val3 as t1val3,t2.val3 as t2val3
    FROM TAB001 t1 LEFT OUTER JOIN TAB001 t2
    ON t1.col2 = t2.col2;

    Materialized view created.

    SQL> exec dbms_mview.refresh('MV001','F');
    BEGIN dbms_mview.refresh('MV001','F'); END;

    *
    ERROR at line 1:
    ORA-12004: REFRESH FAST cannot be used for materialized view "U1"."MV001"
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2809
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 3025
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2994
    ORA-06512: at line 1

    SQL>

    此时,可以考虑换用 ROWID 类型的 MVIEW LOG,重新来执行一次:

    create table TAB001 (col1 integer primary key, col2 integer, val3 integer);

    alter table tab001 add constraint con_t1_col2 unique(col2);

    CREATE MATERIALIZED VIEW LOG ON tab001 WITH ROWID;


    create table TAB002 (col1 integer primary key, col2 integer, val3 integer);

    CREATE MATERIALIZED VIEW LOG ON tab002 WITH ROWID;


    CREATE MATERIALIZED VIEW MV055
     BUILD IMMEDIATE
     REFRESH FAST
     AS select  /*+ use_hash(a,b) */
        a.rowid aid, b.rowid bid, a.col1, b.val3
        from tab001 a, tab002 b
        where a.col2 = b.col2(+);

    exec dbms_mview.refresh('MV055','F');

    SQL> exec dbms_mview.refresh('MV055','F');

    PL/SQL procedure successfully completed.

    SQL>

    可以看到,已经成功。

  • 相关阅读:
    Super超级ERP系统---(1)总体设计
    推荐三款强大的Js图表库
    PHP session锁
    关于MVC的一些思考
    git 设置ssh无密码登录
    一个临时性页面的优化
    Redis系列三:Redis常用设置
    根据省份等地址获取经纬度,或根据经纬度获取地址信息
    Redis系列二:Redis支持的数据类型和使用方法(二)
    Redis系列二:Redis支持的数据类型和使用方法(一)
  • 原文地址:https://www.cnblogs.com/gaojian/p/9069018.html
Copyright © 2020-2023  润新知