oracle 10G ÎﻯÊÓͼÐÂÌØÐÔ(²âÊÔЧ¹û²»ÀíÏë)
http://mrhaozi.itpub.net/post/41048/495175
ÎﻯÊÓͼ
ÀûÓÃÇ¿ÖƲéѯÖØдºÍеÄÇ¿´óµÄµ÷Õû¹ËÎʳÌÐò — ËüÃÇʹÄú²»ÔÙÐèҪƾ²Â²â½øÐй¤×÷ — µÄÒýÈ룬ÔÚ 10g ÖйÜÀíÎﻯÊÓͼ±äµÃ¸ü¼ÓÈÝÒ×
ÎﻯÊÓͼ (MV) — Ò²³ÆΪ¿ìÕÕ — Ò»¶Îʱ¼äÀ´ÒѾ¹ã·ºÊ¹Óá£MV ÔÚÒ»¸ö¶ÎÖд洢²éѯ½á¹û£¬²¢ÇÒÄܹ»ÔÚÌá½»²éѯʱ½«½á¹û·µ»Ø¸øÓû§£¬´Ó¶ø²»ÔÙÐèÒªÖØÐÂÖ´Ðвéѯ — ÔÚ²éѯҪִÐм¸´Îʱ£¨ÕâÔÚÊý¾Ý²Ö¿â»·¾³Öзdz£³£¼û£©£¬ÕâÊÇÒ»¸öºÜ´óµÄºÃ´¦¡£ÎﻯÊÓͼ¿ÉÒÔÀûÓÃÒ»¸ö¿ìËÙˢлúÖÆ´Ó»ù´¡±íÖÐÈ«²¿»òÔöÁ¿Ë¢Ð¡£
¼Ù¶¨ÄúÒѾ¶¨ÒåÁËÒ»¸öÎﻯÊÓͼ£¬ÈçÏ£º
create materialized view mv_hotel_resv
refresh fast
enable query rewrite
as
select distinct city, resv_id, cust_name
from hotels h, reservations r
where r.hotel_id = h.hotel_id';
ÄúÈçºÎ²ÅÄÜÖªµÀÒѾΪÕâ¸öÎﻯÊÓͼ´´½¨ÁËÆäÕý³£¹¤×÷Ëù±ØÐèµÄËùÓжÔÏó£¿ÔÚ Oracle Êý¾Ý¿â 10g ֮ǰ£¬ÕâÊÇÓà DBMS_MVIEW ³ÌÐò°üÖÐµÄ EXPLAIN_MVIEW ºÍEXPLAIN_REWRITE ¹ý³ÌÀ´Åжϵġ£ÕâЩ¹ý³Ì£¨ÔÚ 10g ÖÐÈÔÈ»Ìṩ£©·Ç³£¼òÒªµØ˵Ã÷Ò»ÖÖÌض¨µÄ¹¦ÄÜ — Èç¿ìËÙˢй¦ÄÜ»ò²éѯÖØд¹¦ÄÜ — ¿ÉÄÜÓÃÓÚÉÏÊöµÄÎﻯÊÓͼ£¬µ«²»ÌṩÈçºÎʵÏÖÕâЩ¹¦ÄܵĽ¨Òé¡£Ïà·´£¬ÐèÒª¶Ôÿһ¸öÎﻯÊÓͼµÄ½á¹¹½øÐÐÄ¿ÊÓ¼ì²é£¬ÕâÊǷdz£²»Êµ¼ÊµÄ¡£
ÔÚ 10g ÖУ¬Ð嵀 DBMS_ADVISOR ³ÌÐò°üÖеÄÒ»¸öÃûΪ TUNE_MVIEW µÄ¹ý³ÌʹµÃÕâÏ×÷±äµÃ·Ç³£ÈÝÒ×£ºÄúÀûÓà IN ²ÎÊýÀ´µ÷ÓóÌÐò°ü£¬Õâ¹¹ÔìÁËÎﻯÊÓͼ´´½¨½Å±¾µÄÈ«²¿ÄÚÈÝ¡£¸Ã¹ý³Ì´´½¨Ò»¸ö¹ËÎʳÌÐòÈÎÎñ (Advisor Task)£¬ËüÓµÓÐÒ»¸öÌض¨µÄÃû³Æ£¬½öÀûÓà OUT ²ÎÊý¾ÍÄܹ»°ÑÕâ¸öÃû³Æ´«»Ø¸øÄú¡£
ÏÂÃæÊÇÒ»¸öÀý×Ó¡£ÒòΪµÚÒ»¸ö²ÎÊýÊÇÒ»¸ö OUT ²ÎÊý£¬ËùÒÔÄúÐèÒªÔÚ SQL*Plus Öж¨ÒåÒ»¸ö±äÁ¿À´±£´æËü¡£
SQL> -- Ê×Ïȶ¨ÒåÒ»¸ö±äÁ¿À´±£´æ OUT ²ÎÊý
SQL> var adv_name varchar2(20)
SQL> begin
2 dbms_advisor.tune_mview
3 (
4 :adv_name,
5 'create materialized view mv_hotel_resv refresh fast enable query rewrite as
select distinct city, resv_id, cust_name from hotels h,
reservations r where r.hotel_id = h.hotel_id');
6* end;
ÏÖÔÚÄú¿ÉÒÔÔڸñäÁ¿ÖÐÕÒ³ö¹ËÎʳÌÐòµÄÃû³Æ¡£
SQL> print adv_name
ADV_NAME
------------
Ïà¹ØÎĵµ£º
ת×Ô£ºhttp://www.cnblogs.com/houxm/archive/2009/08/26/1554481.html
Ïê½â£ºhttp://sunwayle.blog.51cto.com/114995/102516
Oracle »ØÊÕÕ¾¹¦ÄÜ,³¹µ×ɾ³ý±í
Oracle 10g
ÖгöÏÖ±íÃû£ºBIN$2cMp4FjwQ2Cw3Lj+BxLYTw==$0
×î½ü·¢ÏÖOracleÖгöÏÖÁËÕâЩÆæ¹ÖµÄ±íÃû£¬ÉÏÍø²éÕÒºó·¢ÏÖÊÇoracle10gµÄ»ØÊÕÕ¾¹¦ÄÜ£¬²¢Ã»Óг¹µ×µÄɾ³ ......
·½°¸Ò»£º
ÐÂ×°ÁËϵͳºó£¬·¢ÏÖÔÚµ÷ÊÔ³ÌÐòʱTOMCATÌáʾ8080¶Ë¿ÚÒѱ»Õ¼Óã¬ÓÚÊÇÔËÐÐNETSTAT -ANO²é¿´¶Ë¿ÚʹÓÃÇé¿ö£¬·¢ÏÖ8080¶Ë¿Ú±»ORACLEµÄ¼àÌýÆ÷¸øÕ¼ÓÃÁË£¬ÓÚÊǽáºÏÉÏÍø²éµ½·½·¨£¬½«ORACLE XDBµÄHTTP·þÎñ¶Ë¿Ú¸Ä³É8081£¬ÎÊÌâ½â¾ö¡£
×ܽáһϿɽâ¾öµÄ·½ ......
-- Create the user
create user SMCQUERY
identified by SMCQUERY;
-- Grant/Revoke role privileges
grant connect to SMCQUERY;
-- Grant/Revoke system privileges
grant select any table to SMCQUERY;
grant debug any procedure to SMCQUERY;
grant debug connect session to SMCQUERY;
grant cr ......
1¡£select * from a where a.rowid=(select min(b.rowid) from b where a.id=b.id);
create test1(
nflowid number primary key,
ndocid number,
drecvdate date);
insert into test1 values (1, 12301, sysdate) ;
insert into test1 values (2, 12301, sysdate);
select * from test1 order by drecvdate:
......