10G開始Oracle區分物化檢視和表
在9i以前,很多功能都是不區分表和物化檢視的區別的,到了10g以後。很多功能會將表和物化檢視區分對待。
原本通用的COMMENT ON TABLE語句,對物化檢視不再有效,必須要使用COMMENT ON MATERIALIZED VIEW語句代替。
SQL> SELECT * FROM V$VERSION;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> CREATE TABLE T_BASE (ID NUMBER, TYPE VARCHAR2(30), NUM NUMBER);
Table created.
SQL> CREATE MATERIALIZED VIEW
LOG ON T_BASE
2 WITH ROWID, SEQUENCE (TYPE, NUM)
3 INCLUDING NEW VALUES;
Materialized view log created.
SQL> CREATE MATERIALIZED VIEW
MV_BASE
2 REFRESH FAST ENABLE QUERY REWRITE AS
3 SELECT TYPE, SUM(NUM) SUM_NUM, COUNT(NUM) CNT_NUM, COUNT(*) CNT
4 FROM T_BASE
5 GROUP BY TYPE;
Materialized view created.
SQL> COMMENT ON TABLE MV_BASE IS
'COMMENT ON A MATERIALIZED VIEW ';
COMMENT ON TABLE MV_BASE IS 'COMMENT ON A MATERIALIZED VIEW '
*
ERROR at line 1:
ORA-12098: cannot comment on the materialized view
SQL> COMMENT ON MATERIALIZED VIEW MV_BASE IS 'COMMENT ON A MATERIALIZED VIEW
';
Comment created.
SQL> COL COMMENTS FOR A60
SQL> SELECT * FROM USER_MVIEW_COMMENTS;
MVIEW_NAME COMMENTS
------------------------------
------------------------------------------------------------
MV_BASE COMMENT ON
A MATERIALIZED VIEW
其實不只是COMMENT發生了變化,關於物化檢視的執行計劃Oracle也對其進行細化,將物化檢視的掃描和全表掃描區分開:
SQL> SET AUTOT ON EXP
SQL> SELECT COUNT(*) FROM MV_BASE;
COUNT(*)
----------
0
Execution Plan
----------------------------------------------------------
Plan hash value: 3034976462
-------------------------------------------------------------------------
| Id | Operation | Name | Rows
| Cost (%CPU)| Time |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT |
| 1 | 2
(0)| 00:00:01 |
| 1 |
SORT AGGREGATE | |
1 | | |
| 2 |
MAT_VIEW ACCESS FULL| MV_BASE |
1 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this
statement
SQL> SELECT /*+ REWRITE */ TYPE, COUNT(*) FROM T_BASE GROUP BY TYPE;
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 1008429399
----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows
| Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | |
1 | 30 | 2
(0)| 00:00:01 |
| 1 |
MAT_VIEW REWRITE ACCESS FULL| MV_BASE | 1 |
30 | 2 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this
statement
在9i以前,很難從執行計劃中區分掃描的是表還是物化檢視,但是現在一目瞭然了。
總的來說,這種改進還是很有意義的,使用者可以更清楚的瞭解處理的物件到底是表還是物化檢視。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-723483/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle普通檢視和物化檢視的區別Oracle
- 普通檢視和物化檢視的區別
- 物化檢視妙用__表同步使用物化檢視方法
- oracle物化檢視Oracle
- trigger和物化檢視同步表
- oracle 建立物化檢視Oracle
- Oracle 物化檢視建立Oracle
- Oracle物化檢視詳解Oracle
- ORACLE物化檢視測試Oracle
- Oracle 物化檢視案例分享Oracle
- Oracle物化檢視語法Oracle
- ORACLE物化檢視入門Oracle
- oracle物化檢視系列(二)Oracle
- oracle物化檢視系列(一)Oracle
- 物化檢視日誌表被DROP後建立物化檢視報錯
- oracle 10G 物化檢視新特性(測試效果不理想)Oracle 10g
- 10G物化檢視PCT快速重新整理不再需要物化檢視日誌(三)
- 10G物化檢視PCT快速重新整理不再需要物化檢視日誌(二)
- 10G物化檢視PCT快速重新整理不再需要物化檢視日誌(一)
- CUUG oracle物化檢視講解Oracle
- Oracle物化檢視3 - Prebuilt MVOracleUI
- Oracle 物化檢視 例項一Oracle
- Oracle物化檢視及SnapshotOracle
- ORACLE中的物化檢視建立Oracle
- Oracle如何根據物化檢視日誌快速重新整理物化檢視Oracle
- 【MVIEW】Oracle通過物化檢視同步表資料及簡介ViewOracle
- Oracle 物化檢視1 - 單表聚合及其快速重新整理Oracle
- 【物化檢視】幾種物化檢視日誌分析
- Oracle 物化檢視 詳細錯誤描述 檢視方法Oracle
- Oracle 11g 建立物化檢視Oracle
- oracle 物化檢視重新整理方法Oracle
- oracle物化檢視日誌系列(一)Oracle
- oracle物化檢視日誌系列(二)Oracle
- oracle物化檢視日誌系列(三)Oracle
- 檢視和表的區別
- 建立遠端基表的物化檢視
- Oracle 常用效能檢視一覽表(10g)Oracle
- 【物化檢視】根據物化檢視日誌快速重新整理物化檢視的過程