ORACLEÎﻯÊÓͼ Query RewriteµÄÒ»°ãÀí½âÖ®Îå
¶ÔÓÚÒ»¸ö¸ø¶¨µÄSQL, ºÍÏÖÓеÄMVIEW, Õâ¸öSQL¿ÉÄܱ»Rewrite, Ò²¿ÉÄܲ»Äܱ»Rewrite, ÈçºÎÕÒ³öÕâÆäÖеÄÔÒòÄØ, ¿¿¾Ñé¿ÉÒÔ½â¾öһЩÎÊÌâ, ²»¹ýËù»¨µÄʱ¼ä¾ÍÒª³¤Ò»µãÁË. ÆäʵÔÚOracleÖÐÌṩÁËÒ»¸öº¯Êý¿ÉÒÔÓÃÓÚ½âÊÍΪʲôij¸öSQL²»Äܱ»ÖØд, Õâ¸ö¹ý³ÌλÓÚdbms_mviewÕâ¸ö°üÖÐ, ¹ý³ÌÃûΪexplain_rewrite, ÓÐÁËÕâ¸ö¹¤¾ß, ¿ÉÒÔ¿ìËÙµØÕÒ³öΪʲô²»Äܱ»ÖØд, ҪʹÓÃÕâ¸ö¹ý³Ì, ÄãÐèÒªÊÂÏÈ´´½¨Ò»¸ö±íREWRITE_TABLE, ¿ÉÒÔͨ¹ý@?/rdbms/admin/utlxrw.sqlÀ´´´½¨.
CREATE TABLE REWRITE_TABLE
(
statement_id VARCHAR2(30), -- id for the query
mv_owner VARCHAR2(30), -- owner of the MV
mv_name VARCHAR2(30), -- name of the MV
sequence INTEGER, -- sequence no of the error msg
query VARCHAR2(2000),-- user query
message VARCHAR2(512), -- EXPLAIN_REWRITE error msg
pass VARCHAR2(3), -- rewrite pass no
flags INTEGER, -- associated flags
reserved1 INTEGER, -- currently not used
reserved2 VARCHAR2(10) -- currently not used
)
ÓÐÁËÕâ¸
Ïà¹ØÎĵµ£º
±¾´Îoracle dataguard
»·¾³£º
²Ù×÷ϵͳ£ºwindows 2003 server
Êý¾Ý¿â£ºoracle 10g 10.2.0.1
ORACLE_HOME£ºD:\oracle\product\10.2.0\db_1
archive_dest£ºD:\archivelog
rman_dest£ºd:\rman_backup
»úÆ÷£º1̨
Ö÷¿âÃû³Æ£ºlearn
±¸¿âÃû³Æ£ºlearndg
ʵÑé²½Ö裺Ð޸ĺÃtnsnames¡¢listener¡¢pfileÎļþ£¬Í¨¹ýrmanµÄduplic ......
ÔÚOracleµÄQuery RewriteÖÐÖ÷ÒªÓÐÈýµã, µÚÒ»ÊÇҪʹÓÃCBO; µÚ¶þÊÇÒªÉèÖÃquery rewrite enabled²ÎÊýΪTRUE; µÚÈýÊÇÒªÏÈÔñÉèÖÃquery rewrite integrity²ÎÊýµÄÖµ(stale_tolerated, trusted, enforced). ¶ÔÓÚµÚÒ»µã, ÎÒÃÇ×îºÃanalyzeÏà¹ØµÄ±í¼°Ë÷Òý¼°MV; ¶ÔÓÚµÚ¶þµã,Õâ¸ö²ÎÊýÖ»ÓÐÁ½¸öÖµ(true, false), ºÜ¼òµ ......
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
set colsep |
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
set feedback on
declare cursor cur_no is
select beginno,endno from hm where 1=1;
b ......
¿ÉÒÔ¿´µ½MVIEWÔÚQuery RewriteÖеÄÖØÒªÐÔ, ÒªÔÚʵ¼ÊÓ¦ÓÃÖÐʹÓÃ, ¾ÍµÃÖªµÀËüµÄºÜ¶à·½Ãæ, ÆäÖÐË¢ÐÂÊÇ×îÖ÷ÒªµÄ:
1, MVIEWÈÕÖ¾µÄ½¨Á¢
2, »ã×ÜÐ͵ÄMIVEWµÄË¢ÐÂ
3, JOINÀàÐ͵ÄMVIEWµÄË¢ÐÂ
4, ¸ü¸´ÔÓµÄMVIEWµÄË¢ÐÂ
5, ·ÖÇøʱµÄMVIEWµÄË¢ÐÂ
ÔÚÕâ¶ùÎÒÃÇÖ÷ÒªÌÖÂÛµÄÊÇÈçºÎʵÏÖFastË¢ÐÂ, ·ñÔòûÓжàÉ ......