Oracle MATERIALIZED VIEW ´´½¨ÎﻯÊÓͼ
ÎﻯÊÓͼ¸ÅÊö
OracleµÄÎﻯÊÓͼÌṩÁËÇ¿´óµÄ¹¦ÄÜ£¬¿ÉÒÔÓÃÔÚ²»Í¬µÄ»·¾³ÖС£ÔÚ²»Í¬µÄ»·¾³ÖУ¬ÎﻯÊÓͼµÄ×÷ÓÃÒ²²»Ïàͬ¡£Êý¾Ý²Ö¿âÖеÄÎﻯÊÓͼÖ÷ÒªÓÃÓÚÔ¤ÏȼÆËã²¢±£´æ±íÁ¬½Ó»ò¾Û¼¯µÈºÄʱ½Ï¶àµÄ²Ù×÷µÄ½á¹û£¬ÕâÑù£¬ÔÚÖ´Ðвéѯʱ£¬¾Í¿ÉÒÔ±ÜÃâ½øÐÐÕâЩºÄʱµÄ²Ù×÷£¬¶ø´Ó¿ìËٵĵõ½½á¹û¡£ÔÚÊý¾Ý²Ö¿âÖУ¬»¹¾³£Ê¹ÓòéѯÖØд£¨query rewrite£©»úÖÆ£¬ÕâÑù²»ÐèÒªÐÞ¸ÄÔÓеIJéѯÓï¾ä£¬Oracle»á×Ô¶¯Ñ¡ÔñºÏÊʵÄÎﻯÊÓͼ½øÐвéѯ£¬ÍêÈ«¶ÔÓ¦ÓÃ͸Ã÷¡£ÎﻯÊÓͼºÍ±íÒ»Ñù¿ÉÒÔÖ±½Ó½øÐвéѯ¡£ÎﻯÊÓͼ¿ÉÒÔ»ùÓÚ·ÖÇø±í£¬ÎﻯÊÓͼ±¾ÉíÒ²¿ÉÒÔ·ÖÇø¡£³ýÁËÔÚÊý¾Ý²Ö¿âÖÐʹÓã¬ÎﻯÊÓͼ»¹ÓÃÓÚ¸´ÖÆ¡¢Òƶ¯¼ÆËãµÈ·½Ãæ¡£ÎﻯÊÓͼÓкܶ෽ÃæºÍË÷ÒýºÜÏàËÆ£ºÊ¹ÓÃÎﻯÊÓͼµÄÄ¿µÄÊÇΪÁËÌá¸ß²éѯÐÔÄÜ£»ÎﻯÊÓͼ¶ÔÓ¦ÓÃ͸Ã÷£¬Ôö¼ÓºÍɾ³ýÎﻯÊÓͼ²»»áÓ°ÏìÓ¦ÓóÌÐòÖÐSQLÓï¾äµÄÕýÈ·ÐÔºÍÓÐЧÐÔ£»ÎﻯÊÓͼÐèÒªÕ¼Óô洢¿Õ¼ä£»µ±»ù±í·¢Éú±ä»¯Ê±£¬ÎﻯÊÓͼҲӦµ±Ë¢Ð¡£
´´½¨ÎﻯÊÔͼÖ÷ҪѡÏî˵Ã÷
´´½¨ÎﻯÊÓͼʱ¿ÉÒÔÖ¸¶¨¶àÖÖÑ¡ÏÏÂÃæ¶Ô¼¸ÖÖÖ÷ÒªµÄÑ¡Ïî½øÐмòµ¥ËµÃ÷£º
Ãû³Æ
ON PREBUILD TABLE
ÃèÊö
½«ÒѾ´æÔڵıí×¢²áΪÎﻯÊÓͼ¡£Í¬Ê±»¹±ØÐëÌṩÃèÊö´´½¨¸Ã±íµÄ²éѯµÄ SELECT ×Ӿ䡣¿ÉÄÜÎÞ·¨Ê¼ÖÕ±£Ö¤²éѯµÄ¾«¶ÈÓë±íµÄ¾«¶ÈÆ¥Å䡣ΪÁË¿Ë·þ´ËÎÊÌ⣬Ӧ¸ÃÔڹ淶Öаüº¬ WITH REDUCED PRECISION ×Ӿ䡣
Ãû³Æ
Build Clause
´´½¨·½Ê½
ÃèÊö
°üÀ¨BUILD IMMEDIATEºÍBUILD DEFERREDÁ½ÖÖ
È¡Öµ
BUILD IMMEDIATE
ÔÚ´´½¨ÎﻯÊÓͼµÄʱºò¾ÍÉú³ÉÊý¾Ý
BUILD DEFERRED
ÔÚ´´½¨Ê±²»Éú³ÉÊý¾Ý£¬ÒÔºó¸ù¾ÝÐèÒªÔÚÉú³ÉÊý¾Ý
ĬÈÏ
BUILD IMMEDIATE
Ãû³Æ
Refresh
Ë¢ÐÂ×Ó¾ä
ÃèÊö
µ±»ù±í·¢ÉúÁËDML²Ù×÷ºó£¬ÎﻯÊÓͼºÎʱ²ÉÓÃÄÄÖÖ·½Ê½ºÍ»ù±í½øÐÐͬ²½
Óï·¨
[refresh [fast | complete | force]
[on demand | commit]
[start with date]
[next date]
[with {primary key | rowid}]
]
È¡Öµ
FAST
²ÉÓÃÔöÁ¿Ë¢Ð£¬Ö»Ë¢ÐÂ×ÔÉÏ´ÎË¢ÐÂÒÔºó½øÐеÄÐÞ¸Ä
COMPLETE
¶ÔÕû¸öÎﻯÊÓͼ½øÐÐÍêÈ«µÄË¢ÐÂ
FORCE(ĬÈÏ)
OracleÔÚË¢ÐÂʱ»áÈ¥ÅжÏÊÇ·ñ¿ÉÒÔ½øÐпìËÙˢУ¬Èç¹û¿ÉÒÔÔò²ÉÓÃFast·½Ê½£¬·ñÔò²ÉÓÃCompleteµÄ·½Ê½£¬ForceÑ¡ÏîÊÇĬÈÏÑ¡Ïî
O
Ïà¹ØÎĵµ£º
´ó¼Ò¶¼ÖªµÀ£¬ÓÃPL/SQLÁ¬½ÓOracle£¬ÊÇÐèÒª°²×°Oracle¿Í»§¶ËÈí¼þµÄ¡£ÓÐûҪÏë¹ý²»°²×°Oracle¿Í»§¶ËÖ±½ÓÁ¬½ÓOracleÄØ£¿
ÆäʵÎÒÒ»Ö±ÏëÕâÑù×ö£¬ÒòΪÕâ¸ö¿Í»§¶ËʵÔÚÌ«ÈÃÈËÌÖÑáÁË£¡£¡£¡²»µ«»á°²×°Ò»¸öJDK£¬¶øÇÒ»¹»á°Ñ×Ô¼º·ÅÔÚ»·¾³±äÁ¿µÄ×îÇ°Ã棬»áÔì³É²»Ð ......
http://www.anysql.net/oracle/oracle_olap_dimension.html
ÔÚOracleµÄÊý¾Ý²Ö¿â(OLAP)ÖÐ, ʵÌ廯ÊÓͼ(MVIEW), ²éѯÖØд(Query Rewrite)ºÍά(Dimension)ÊǷdz£ÖØÒªµÄÓÅ»¯ÊÖ¶Î, ¶ÔÓÚÇ°Á½ÕßÎÒ²»ÏëÔÚÕâ¶ùÖظ´½²ÁË, Ö÷ÒªÀ´ÌåÑéÒ»ÏÂάµÄ×÷ÓÃ. Òª·¢»ÓάµÄ×÷ÓÃ, »¹ÊÇÐèÒªÓõ½Ç°ÃæÁ½Õß, ÏÂÃæÊÇÎÒÉè¼ÆµÄÖ»ÓÐÒ»¸öά±íµÄ×î¼òµ¥µÄÀý×Ó ......
ºÜ¶àÅóÓÑÒªÎÒ°ïæÍƼöÒ»ÏÂOracleµÄÈëÃÅÊé¼®£¬Äܹ»Á˽âOracleµÄ»ù±¾¸ÅÄî¡¢»ù±¾ÖªÊ¶µÄÄÇÖÖ¡£
ÎÒ¾ÍÃâΪÆäÄÑ£¬ÍƼö¼¸±¾¡£
Ê×ÏÈÎÒÏëÇ¿µ÷µÄÒ»µãÊÇ£¬ÈκÎÒ»±¾ÏµÍ³µÄOracleÊé¼®Ö»ÒªÈÏÕæ¶ÁÏÂÀ´£¬¶¼»áÓв»´íµÄÊÕ»ñ£¬¶ÁÊé×î¼É»äµÄÊÇ»¢Í·Éßβ£¬Ç³³¢ÔòÖ¹¡£
1.µÚÒ»±¾ÒªÍƼö¸ø´ó¼ÒµÄÊÇOracleµÄ¸ÅÄîÊֲᣬÕâ±¾ÊÖ²áÊÇÎÞÊýDBAѧϰµÄÆðµã£ ......
·ÖÒ³²éѯ¸ñʽ£º
SELECT * from
(
SELECT A.*, ROWNUM RN
from (SELECT * from TABLE_NAME) A
WHERE ROWNUM <= 40
)
WHERE RN >= 21
ÆäÖÐ×îÄÚ²ãµÄ²éѯSELECT * from TABLE_NAME±íʾ²»½øÐзҳµÄÔʼ²éѯÓï¾ä¡£ROWNUM <= 40ºÍRN >= 21¿ØÖÆ·ÖÒ³²éѯµÄÿҳµÄ·¶Î§¡£
ÉÏÃæ¸ø³öµÄÕâ¸ö·ÖÒ³²éѯÓï¾ä£¬ÔÚ´ó¶à ......