mview on prebuilt table用法嘗試
物化檢視的on prebuilt table特性可以用於減少跨平臺不同host之間資料遷移的業務中斷時間,對於7*24小時的應用系統是很實用的,以下是在同一臺host上的試驗,主要是掌握原理.對於不同host的實際情況,無非是多建立一個dblink的問題.
[@more@]SQL> create table a (col1 varchar2(20),col2 number);
Table created.
SQL> create table b (col1 varchar2(20),col2 number);
Table created.
SQL> alter table a add constraint pk_a primary key(col1);
Table altered.
SQL> insert into a values('1',1);
1 row created.
SQL> insert into a values('2',2);
1 row created.
SQL> commit;
Commit complete.
SQL> create materialized view log on a with primary key;
Materialized view log created.
SQL> create materialized view b on prebuilt table
2 as select * from a;
Materialized view created.
SQL> select object_name,object_type from user_objects
2 where object_name='B';
OBJECT_NAME
OBJECT_TYPE
----------------------------------------------
B TABLE
B
MATERIALIZED VIEW
2 rows selected.
SQL> select count(*) from b;
COUNT(*)
----------
0
1 row selected.
SQL> exec dbms_mview.refresh('b','c');
PL/SQL procedure successfully completed.
SQL> select * from b;
COL1 COL2
-------------------- ----------
1 1
2 2
2 rows selected.
SQL> insert into a values('3','3');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from a;
COL1 COL2
-------------------- ----------
1 1
2 2
3 3
3 rows selected.
SQL> insert into a values('4',4);
1 row created.
SQL> commit;
Commit complete.
SQL> exec dbms_mview.refresh('b','f');
PL/SQL procedure successfully completed.
SQL> select * from b;
COL1 COL2
-------------------- ----------
1 1
2 2
3 3
4 4
4 rows selected.
SQL> select object_name,object_type from user_objects
2 where object_name='B';
OBJECT_NAME OBJECT_TYPE
------------------------------------------------------------
B TABLE
B MATERIALIZED VIEW
2 rows selected.
SQL> drop materialized view b;
Materialized view dropped.
SQL> select object_name,object_type from user_objects
2 where object_name='B';
OBJECT_NAME OBJECT_TYPE
------------------------------------------------------
B TABLE
1 row selected.
SQL> select * from b;
COL1 COL2
-------------------- ----------
1 1
2 2
3 3
4 4
4 rows selected.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/75730/viewspace-811685/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Bug 9369183 - ORA-32349 creating MView on prebuilt table using select from remote tableViewUIREM
- 使用 on prebuilt table 建立物化檢視 (ZT)UI
- 使用 on prebuilt table 建立物化檢視(zt)UI
- 使用prebuilt table 方式遷移資料UI
- 建立DBMS_MVIEW.EXPLAIN_MVIEW分析需要表MV_CAPABILITIES_TABLEViewAI
- 嘗試
- JAVAFX嘗試Java
- 嘗試1
- DML對prebuilt table的內容修改時出現ORA-01732UI
- 初嘗試swiftSwift
- ios NFC嘗試iOS
- oracle table()函式用法Oracle函式
- 嘗試 LeetcodeLeetCode
- 嘗試手寫promisePromise
- 初次嘗試HTTPSHTTP
- Redis crackit 漏洞嘗試Redis
- 嘗試 Leetcode(二)LeetCode
- 微信小程式 TypeScript 嘗試微信小程式TypeScript
- oracle函式初次嘗試Oracle函式
- PL/SQL表---table()函式用法SQL函式
- table控制元件的基本用法控制元件
- Oracle物化檢視DBMS_MVIEW.EXPLAIN_MVIEW包的使用OracleViewAI
- oracle10g物化檢視之dbms_mview.explain_mviewOracleViewAI
- 基於 Redis 的 LBS 嘗試Redis
- MyBatis Generator嘗試與踩坑MyBatis
- React最佳實踐嘗試(三)React
- React最佳實踐嘗試(二)React
- ChatGPT技術國產化嘗試ChatGPT
- 服務管理框架的嘗試框架
- struts國際化程式嘗試
- linux模擬windows嘗試LinuxWindows
- display:table-cell的用法簡介
- dbms_mview系列(六)View
- dbms_mview系列(五)View
- dbms_mview系列(四)View
- dbms_mview系列(三)View
- dbms_mview系列(二)View
- dbms_mview系列(一)View