物化檢視匯出匯入可能導致物化檢視日誌的失效

楊奇龍發表於2010-07-21

SQL> create user yang identified by yang;
使用者已建立。
已用時間:  00: 00: 00.10
SQL> grant resource,connect to yang;
授權成功。
已用時間:  00: 00: 00.01
SQL> grant create meterialized view to yang;
grant create meterialized view to yang
      *
第 1 行出現錯誤:
ORA-00990: 許可權缺失或無效
已用時間:  00: 00: 00.01
SQL> show user
USER 為 "SYS"
SQL> grant create materialized view to yang;
授權成功。
已用時間:  00: 00: 00.00
SQL> create user b identified by b;
使用者已建立。
已用時間:  00: 00: 00.01
SQL> grant create materialized view to b;
授權成功。
已用時間:  00: 00: 00.00
SQL> grant create materialized view to b;
授權成功。
已用時間:  00: 00: 00.04
SQL> conn yang/yang
已連線。
SQL> select * from tab;
未選定行
已用時間:  00: 00: 00.07
SQL> create table t(id number primary key);
表已建立。
已用時間:  00: 00: 00.21
SQL> insert into t values(1);
已建立 1 行。
已用時間:  00: 00: 00.01
SQL> col change_vector$$ format a40
SQL> select * from mlog$_t;
select * from mlog$_t
              *
第 1 行出現錯誤:
ORA-00942: 表或檢視不存在
已用時間:  00: 00: 00.00
SQL> select * from sys.mlog$_t;
select * from sys.mlog$_t
                  *
第 1 行出現錯誤:
ORA-00942: 表或檢視不存在

已用時間:  00: 00: 00.00
SQL> rollback;
回退已完成。
已用時間:  00: 00: 00.04
SQL> create materialized view log on t;
實體化檢視日誌已建立。
已用時間:  00: 00: 00.39
SQL> create materialized view mv_t as select * from t;
實體化檢視已建立。
已用時間:  00: 00: 01.21
SQL> insert into t values(1);
已建立 1 行。
已用時間:  00: 00: 00.04
SQL> col change_vector$$ format a40
SQL> select * from mlog$_t;

        ID SNAPTIME$$     D O CHANGE_VECTOR$$                                  
---------- -------------- - - ----------------------------------------         
         1 01-1月 -00     I N FE                                               
已用時間:  00: 00: 00.00
SQL> commit;
提交完成。
已用時間:  00: 00: 00.00
SQL> exec dbms_mview.refresh('mv_t');
PL/SQL 過程已成功完成。
已用時間:  00: 00: 00.79
SQL> commit;
提交完成。
已用時間:  00: 00: 00.00
SQL> select * from mv_t;
        ID                                                                     
----------                                                                     
         1                                                                     
已用時間:  00: 00: 00.00
SQL> grant resource,connect to b;
grant resource,connect to b
*
第 1 行出現錯誤:
ORA-01031: 許可權不足
已用時間:  00: 00: 00.04
SQL> conn system/yang as sysdba
已連線。
SQL> grant resource,connect to b;
授權成功。
已用時間:  00: 00: 00.01
SQL> conn yang/yang
已連線。
已用時間:  00: 00: 00.01
SQL> insert into t values (2);
已建立 1 行。
已用時間:  00: 00: 00.00
SQL> select * from mlog$_t;

        ID SNAPTIME$$     D O CHANGE_VECTOR$$                                  
---------- -------------- - - ----------------------------------------         
         2 01-1月 -00     I N FE                                               
已用時間:  00: 00: 00.00
SQL> conn b/b
已連線。
SQL> select * from mlog$_t;
未選定行
已用時間:  00: 00: 00.00
SQL> select * from tab;
TNAME                          TABTYPE  CLUSTERID                              
------------------------------ ------- ----------                              
MLOG$_T                        TABLE                                           
MV_T                           TABLE                                           
RUPD$_T                        TABLE                                           
T                              TABLE                                           
已用時間:  00: 00: 00.03
SQL> select * from t;
        ID                                                                     
----------                                                                     
         1                                                                     

已用時間:  00: 00: 00.01
SQL> select * from mv_t;
        ID                                                                     
----------                                                                     
         1                                                                     

已用時間:  00: 00: 00.01
SQL> insert into t values (2);
已建立 1 行。
已用時間:  00: 00: 00.00
SQL> select * from t;
        ID                                                                     
----------                                                                     
         1                                                                     
         2                                                                     

已用時間:  00: 00: 00.00
SQL> select * from mv_t;
        ID                                                                     
----------                                                                     
         1                                                                     

已用時間:  00: 00: 00.00
SQL> exec dbms_mview.refresh('mv_t');
BEGIN dbms_mview.refresh('mv_t'); END;

*
第 1 行出現錯誤:
ORA-12018: 在建立 "B"."MV_T" 的程式碼時出現以下錯誤
ORA-01741: 非法的零長度識別符號
ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2537
ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2743
ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2712
ORA-06512: 在 line 1

已用時間:  00: 00: 00.57
SQL> conn yang/yang
已連線。
SQL> select * from t;
        ID                                                                     
----------                                                                     
         1                                                                     
         2                                                                     

已用時間:  00: 00: 00.01
SQL> select * from mv_t;
        ID                                                                     
----------                                                                     
         1                                                                     
已用時間:  00: 00: 00.01
SQL> exec dbms_mview.refresh('mv_t');
PL/SQL 過程已成功完成。
已用時間:  00: 00: 00.42
SQL> select * from mv_t;
        ID                                                                     
----------                                                                     
         1                                                                     
         2                                                                     
已用時間:  00: 00: 00.00
SQL> select * from t;
        ID                                                                     
----------                                                                     
         1                                                                     
         2                                                                     

已用時間:  00: 00: 00.00

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-668661/,如需轉載,請註明出處,否則將追究法律責任。

相關文章