OracleÎﻯÊÓͼ¼ò½é¼°ÊµÕ½
1.1.1 OracleÎﻯÊÓͼ¼ò½é
1. ÎﻯÊÓͼ˵Ã÷
ÎﻯÊÓͼ (Materialized View)£¬ÔÚÒÔÇ°µÄOracle°æ±¾ÖгÆΪ¿ìÕÕ(Snapshot)¡£Oracle µÄÎﻯÊÓͼÌṩÁËÇ¿´óµÄ¹¦ÄÜ£¬¿ÉÒÔÓÃÓÚÔ¤ÏȼÆËã²¢±£´æ±íÁ¬½Ó»ò¾Û¼¯µÈºÄʱ½Ï¶àµÄ²Ù×÷µÄ½á¹û£¬ÕâÑùÔÚÖ´Ðвéѯʱ£¬¾Í¿ÉÒÔ±ÜÃâ½øÐÐÕâЩºÄʱµÄ²Ù×÷£¬¶ø´Ó¿ìËٵصõ½½á¹û£º
ÎﻯÊÓͼÓкܶ෽ÃæºÍË÷ÒýºÜÏàËÆ£º
ʹÓÃÎﻯÊÓͼµÄÄ¿µÄÊÇΪÁËÌá¸ß²éѯÐÔÄÜ
ÎﻯÊÓͼ¶ÔÓ¦ÓÃ͸Ã÷£¬Ôö¼ÓºÍɾ³ýÎﻯÊÓͼ²»»áÓ°ÏìÓ¦ÓóÌÐòÖÐSQLÓï¾äµÄÕýÈ·ÐÔºÍÓÐЧÐÔ
ÎﻯÊÓͼÐèÒªÕ¼Óô洢¿Õ¼ä
µ±»ù±í·¢Éú±ä»¯Ê±£¬ÎﻯÊÓͼҲӦµ±Ë¢ÐÂ
ÎﻯÊÓͼ¿ÉÒÔ·ÖΪÒÔÏÂÈýÖÖÀàÐÍ£º
°üº¬¾Û¼¯µÄÎﻯÊÓͼ
Ö»°üº¬Á¬½ÓµÄÎﻯÊÓͼ
ǶÌ×ÎﻯÊÓͼ
ÎﻯÊÓͼ¿ÉÒÔ½øÐзÖÇø¡£¶øÇÒ»ùÓÚ·ÖÇøµÄÎﻯÊÓͼ¿ÉÒÔÖ§³Ö·ÖÇø±ä»¯¸ú×Ù£¨PCT£©¡£¾ßÓÐÕâÖÖÌØÐÔµÄÎﻯÊÓͼ£¬µ±»ù±í½øÐÐÁË·ÖÇøά»¤²Ù×÷ºó£¬ÈÔÈ»¿ÉÒÔ½øÐпìËÙˢвÙ×÷¡£¶ÔÓÚ¾Û¼¯ÎﻯÊÓͼ£¬¿ÉÒÔÔÚGROUP BYÁбíÖÐʹÓÃCUBE»òROLLUP£¬À´½¨Á¢²»Í¬µÈ¼¶µÄ¾Û¼¯ÎﻯÊÓͼ
2. ÎﻯÊÓͼÏêϸ˵Ã÷
1. refresh [fast|complete|force] ÊÓͼˢеķ½Ê½:
fast: ÔöÁ¿Ë¢ÐÂ.¼ÙÉèÇ°Ò»´ÎˢеÄʱ¼äΪt1,ÄÇôʹÓÃfastģʽˢÐÂÎﻯÊÓͼʱ,Ö»ÏòÊÓͼÖÐÌí¼Ót1µ½µ±Ç°Ê±¼ä¶ÎÄÚ,Ö÷±í±ä»¯¹ýµÄÊý¾Ý.ΪÁ˼ǼÕâÖֱ仯£¬½¨Á¢ÔöÁ¿Ë¢ÐÂÎﻯÊÓͼ»¹ÐèÒªÒ»¸öÎﻯÊÓͼÈÕÖ¾±í¡£create materialized view log on £¨Ö÷±íÃû£©¡£
complete:È«²¿Ë¢Ð¡£Ï൱ÓÚÖØÐÂÖ´ÐÐÒ»´Î´´½¨ÊÓͼµÄ²éѯÓï¾ä¡£
force: ÕâÊÇĬÈϵÄÊý¾Ýˢз½Ê½¡£µ±¿ÉÒÔʹÓÃfastģʽʱ£¬Êý¾Ýˢн«²ÉÓÃfast·½Ê½£»·ñÔòʹÓÃcomplete·½Ê½¡£
2.MVÊý¾ÝˢеÄʱ¼ä£º
on demand:ÔÚÓû§ÐèҪˢеÄʱºòˢУ¬ÕâÀï¾ÍÒªÇóÓû§×Ô¼º¶¯ÊÖȥˢÐÂÊý¾ÝÁË£¨Ò²¿ÉÒÔʹÓÃjob¶¨Ê±Ë¢Ð£©
on commit:µ±Ö÷±íÖÐÓÐÊý¾ÝÌá½»µÄʱºò£¬Á¢¼´Ë¢ÐÂMVÖеÄÊý¾Ý£»
start ……£º´ÓÖ¸¶¨µÄʱ¼ä¿ªÊ¼£¬Ã¿¸ôÒ»¶Îʱ¼ä£¨ÓÉnextÖ¸¶¨£©¾ÍË¢ÐÂÒ»´Î£»
ÎﻯÊÓͼ¿ÉÒÔ·ÖΪÒÔÏÂÈýÖÖÀàÐÍ£º°üº¬¾Û¼¯µÄÎﻯÊÓͼ£»Ö»°üº¬Á¬½ÓµÄÎﻯÊÓͼ£»Ç¶Ì×ÎﻯÊÓͼ¡£ÈýÖÖÎﻯÊÓͼµÄ¿ìËÙˢеÄÏÞÖÆÌõ¼þÓкܴóÇø±ð£¬¶ø¶ÔÓÚÆäËû·½ÃæÔòÇø±ð²»´ó¡£´´½¨ÎﻯÊÓͼʱ¿ÉÒÔÖ¸¶¨¶àÖÖÑ¡ÏÏÂÃæ¶Ô¼¸ÖÖÖ÷ÒªµÄÑ¡Ôñ½øÐмòµ¥ËµÃ÷£º
´´½¨·½Ê½£¨Build Methods£©£º°üÀ¨BUILD IMMEDIATEºÍBUILD DEFER
Ïà¹ØÎĵµ£º
ÔÚÒ»°ãµÄPL/SQL³ÌÐò¿ª·¢ÖУ¬¿ÉÒÔʹÓÃSQLµÄDMLÓï¾äºÍÊÂÎñ¿ØÖÆÓï¾ä£¬µ«ÊÇDDLÓï¾ä¼°»á»°Óï¾äÈ´²»ÄÜÔÚPL/SQLÖÐÖ±½ÓʹÓã¬ÒªÏëʵÏÖÔÚPL/SQLÖÐʹÓÃDDLÓï¾ä¼°»á»°¿ØÖÆÓï¾ä£¬¿ÉÒÔͨ¹ý¶¯Ì¬SQLÀ´ÊµÏÖ¡£
Ëùν¶¯Ì¬SQLÊÇÖ¸ÔÚPL/SQL¿é±àÒëʱSQLÓï¾äÊDz»È·¶¨µÄ£¬ÀýÈç¸ù¾ÝÓû§ÊäÈë²ÎÊýµÄ²»Í¬¶ø ......
ÎÄÕÂÌáµ½£¬ÓÃCache hit ratioµÄ·½·¨À´¼ì²éORACLEÐÔÄÜÎÊÌâ¹ýʱÁË£¬ÀïÃæÓоä·Ç³£ÐÎÏóµÄ»°£ºÕâÎÞÒìÓÚÒ»¸öÒ½ÉúÖ»ÖªµÀ¸ù¾ÝѪѹµÄÀ´ÖÎÁƲ¡ÈË£¬¶ø²¡ÈËÓÉÓÚÌÛÍ´£¬Éñ¾ÐË·Ü£¬ÑªÑ¹ÔÚÒ»¸öºÏÀíµÄ·¶Î§ÄÚ£¬Ò½ÉúÈ´¸æËß»¼Õߣ¬Äãû²¡£¬µÈÄãѪѹµÍµÄʱºòÔÙÀ´¡£Í¬ÑùµÄ£¬ÎÒÃDz»Äܽö½ö¸ù¾ÝCache hit ratioÀ´ÅжÏORACLEÊ ......
for example:
15:18:59 SQL> create table t1 (a int, b int);
±íÒÑ´´½¨¡£
ÒÑÓÃʱ¼ä: 00: 00: 00.15
......
1.
´íÎóÌáʾ£ºORA-12545:ÒòÄ¿±êÖ÷»ú»ò¶ÔÏó²»´æÔÚ,Á¬½Óʧ°Ü.
´íÎóÖ¢×´£ºÐ½¨µÄÊý¾Ý¿âÔÚOEM¿ØÖÆ̨ÎÞ·¨ÏÔʾ£¨sysmanÓû§µÇ½£©£¬¶ÀÁ¢Æô¶¯Ä£Ê½¿ÉÒÔÕÒµ½£¬µ«ÎÞ·¨µÇ½£¬³öÏÖÈçÉÏ´íÎó¡£
½â¾ö°ì·¨£ºÐÞ¸Äoracle°²×°Ä¿Â¼Ï£¨oracle\ora90\network\ADMIN£©µÄtnsnames.oraÎļþ£¬½«µ±Ç°Êý¾Ý¿âÌí¼Óµ½¼àÌý¶ÔÏóÖС£ÐÞ¸ÄÖ®ºó£¬¿ÉÒÔÔÚ¶ÀÁ¢Ä ......
Ò»¡¢ÔÚPLSQLÖд´½¨±í£º
create table HWQY.TEST
(
CARNO VARCHAR2(30),
CARINFOID NUMBER
)
¶þ¡¢ÔÚPLSQLÖд´½¨´æ´¢¹ý³Ì£º
create or replace procedure pro_test
AS
carinfo_id number;
BEGIN
select s_CarInfoID.nextval into carinfo_id
from dual;
insert into test(test ......