mv(materialized view)的一點測試
mv在實現簡單的資料同步和資料遷移時非常方便。
是一種空間換時間的思想或者說是一種化整為零的處理思想。
[@more@]SQL> show user
USER is "TEST"
--測試一下fast重新整理,fast重新整理(是指增量重新整理)一定要建立materialzed view log
--==========================================
SQL> create MATERIALIZED view log on t tablespace users;
Materialized view log created.
SQL> create materialized view mv_t tablespace users refresh fast as select * from t ;
Materialized view created.
SQL> select * from mv_t;
no rows selected
SQL> select * from t;
no rows selected
SQL> desc t
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER(38)
NAME VARCHAR2(10)
SQL> insert into t values(1,'a');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- ----------
1 a
SQL> select * from mv_t;
no rows selected
SQL> exec dbms_mview.refresh('mv_t');
PL/SQL procedure successfully completed.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
SQL> insert into t values(2,'a');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
SQL> exec dbms_mview.refresh('mv_t');
PL/SQL procedure successfully completed.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
2 a
SQL> insert into t values(3,'a');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
2 a
SQL> exec dbms_mview.refresh('mv_t');
PL/SQL procedure successfully completed.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
2 a
3 a
--=====================================================
--測試一下on commit重新整理方式
SQL> create materialized view mv_t2 tablespace users refresh fast on commit as select * from t ;
Materialized view created.
SQL> select * from mv_t2;
ID NAME
---------- ----------
1 a
2 a
3 a
4 a
5 a
6 a
6 rows selected.
SQL> insert into t values(7,'a');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from mv_t2;
ID NAME
---------- ----------
1 a
2 a
3 a
4 a
5 a
6 a
7 a
7 rows selected.
SQL>
--=====================================
--測試一下oracle對實體化檢視日誌的自動維護
SQL> desc mlog$_t
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER
SNAPTIME$$ DATE
DMLTYPE$$ VARCHAR2(1)
OLD_NEW$$ VARCHAR2(1)
CHANGE_VECTOR$$ RAW(255)
SQL> col CHANGE_VECTOR$$ format a10
SQL> select *from mlog$_t;
no rows selected
SQL> insert into t values(9,'a');
1 row created.
--插入資料之後mlog$_t裡面記錄了日誌
SQL> select *from mlog$_t;
ID SNAPTIME$$ D O CHANGE_VEC
---------- ------------------- - - ----------
9 4000/01/01 00:00:00 I N FE
SQL> select * from mv_t2;
ID NAME
---------- ----------
1 a
2 a
3 a
4 a
5 a
6 a
7 a
8 a
8 rows selected.
SQL> commit;
Commit complete.
SQL> select * from mv_t2;
ID NAME
---------- ----------
1 a
2 a
3 a
4 a
5 a
6 a
7 a
8 a
9 a
9 rows selected.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
2 a
3 a
4 a
6 a
5 a
8 a
7 a
8 rows selected.
SQL> exec dbms_mview.refresh('mv_t');
PL/SQL procedure successfully completed.
SQL> select * from mv_t;
ID NAME
---------- ----------
1 a
2 a
3 a
4 a
6 a
5 a
8 a
7 a
9 a
9 rows selected.
SQL> select *from mlog$_t;
no rows selected
SQL>
--很顯然mv_t重新整理之後oracle自動清除了mlog$_t裡面的記錄。也就是說實體化檢視日誌的內容
預設oracle是自動維護的。一個基本只能建立一個materialized view log,基於這張基表可以建立
若干materialized view,只要一個materialized view沒有重新整理完畢,materialized view log
中對應的記錄就不會被清除。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1058554/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 建立物化檢視MV ( Materialized View )ZedView
- 物化檢視(Materialized View)的重新整理回滾測試ZedView
- Materialized ViewZedView
- setting up materialized view sites for oracle10g advanced replication mvZedViewOracle
- materialized view 的總結ZedView
- drop materialized view hung !!!ZedView
- about materialized view and long(turn)ZedView
- materialized view (物化檢視)ZedView
- 利用materialized view同步資料ZedView
- materialized view基礎知識ZedView
- Materialized View Logs (190)ZedView
- 11g中的materialized view logZedView
- materialized view的fast和日誌分析和一則案例ZedViewAST
- Oracle vs PostgreSQL Develop(20) - Materialized ViewOracleSQLdevZedView
- Synonym_View_Materialized和Public物件ViewZed物件
- How to Monitor the Progress of a Materialized View Refresh (MVIEW)ZedView
- Android單元測試-對View的測試AndroidView
- 轉:物化檢視(Materialized View)介紹ZedView
- cursor express的一點測試!Express
- Data Warehouse Guide閱讀筆記(八):materialized view之一GUIIDE筆記ZedView
- 【MW】Drop Materialized View Hangs with 'Enq: JI - Contention'ZedViewENQ
- 測試流程與測試人員配置的一點感想
- Index Joins的一點測試!Index
- 建立Materialized view log時是否使用sequence clause的差別ZedView
- oracle10g materialized view物化檢視示例OracleZedView
- ogg 同步 物化檢視建立限制 Materialized ViewZedView
- MV定義語句中包含Fact的VIEW,能否Rewrite ?View
- MV (Materialed View) 物化檢視的重新整理組View
- 軟體測試流程的一點感悟
- index clusterring cluster的一點測試!Index
- 物化檢視(Materialized View)的重新整理回滾約束ZedView
- 測試的思考點
- 軟體穩定性測試的測試點
- 有關oracle external table的一點測試。Oracle
- 有關lock的一點測試總結!
- 許可權傳遞的一點測試!
- 跨DB主機抓取資料建議用MATERIALIZED VIEWZedView
- nested loops 和hash join的一點測試OOP