SQLÓï¾äÓÅ»¯·½·¨30Àý
ÔÚSQLÓï¾äÓÅ»¯¹ý³ÌÖУ¬ÎÒÃǾ³£»áÓõ½hint,ÏÖ×ܽáÒ»ÏÂÔÚSQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨£º
1. /*+ALL_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
ÀýÈç:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÏìӦʱ¼ä,ʹ×ÊÔ´ÏûºÄ×îС»¯.
ÀýÈç:
SELECT /*+FIRST_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
3. /*+CHOOSE*/
±íÃ÷Èç¹ûÊý¾Ý×ÖµäÖÐÓзÃÎʱíµÄͳ¼ÆÐÅÏ¢,½«»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑµÄÍÌÍÂÁ¿;
±íÃ÷Èç¹ûÊý¾Ý×ÖµäÖÐûÓзÃÎʱíµÄͳ¼ÆÐÅÏ¢,½«»ùÓÚ¹æÔò¿ªÏúµÄÓÅ»¯·½·¨;
ÀýÈç:
SELECT /*+CHOOSE*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
4. /*+RULE*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¹æÔòµÄÓÅ»¯·½·¨.
ÀýÈç:
SELECT /*+ RULE */ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
5. /*+FULL(TABLE)*/
±íÃ÷¶Ô±íÑ¡ÔñÈ«¾ÖɨÃèµÄ·½·¨.
ÀýÈç:
SELECT /*+FULL(A)*/ EMP_NO,EMP_NAM from BSEMPMS A WHERE EMP_NO='SCOTT';
6. /*+ROWID(TABLE)*/
ÌáʾÃ÷È·±íÃ÷¶ÔÖ¸¶¨±í¸ù¾ÝROWID½øÐзÃÎÊ.
ÀýÈç:
SELECT /*+ROWID(BSEMPMS)*/ * from BSEMPMS WHERE ROWID>='AAAAAAAAAAAAAA'
AND EMP_NO='SCOTT';
7. /*+CLUSTER(TABLE)*/
ÌáʾÃ÷È·±íÃ÷¶ÔÖ¸¶¨±íÑ¡Ôñ´ØɨÃèµÄ·ÃÎÊ·½·¨,ËüÖ»¶Ô´Ø¶ÔÏóÓÐЧ.
ÀýÈç:
SELECT /*+CLUSTER */ BSEMPMS.EMP_NO,DPT_NO from BSEMPMS,BSDPTMS
WHERE DPT_NO='TEC304' AND BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;
8. /*+INDEX(TABLE INDEX_NAME)*/
±íÃ÷¶Ô±íÑ¡ÔñË÷ÒýµÄɨÃè·½·¨.
ÀýÈç:
SELECT /*+INDEX(BSEMPMS SEX_INDEX) USE SEX_INDEX BECAUSE THERE ARE FEWMALE BSEMPMS */ from BSEMPMS WHERE SEX='M';
9. /*+INDEX_ASC(TABLE INDEX_NAME)*/
±íÃ÷¶Ô±íÑ¡ÔñË÷ÒýÉýÐòµÄɨÃè·½·¨.
ÀýÈç:
SELECT /*+INDEX_ASC(BSEMPMS PK_BSEMPMS) */ from BSEMPMS WHERE DPT_NO='SCOTT';
10. /*+INDEX_COMBINE*/
Ϊָ¶¨±íÑ¡Ôñλͼ·ÃÎÊ·¾,Èç¹ûINDEX_COMBINEÖÐûÓÐÌṩ×÷Ϊ²ÎÊýµÄË÷Òý,½«Ñ¡Ôñ³öλͼË÷ÒýµÄ²¼¶û×éºÏ·½Ê½.
ÀýÈç:
SELECT /*+INDEX_COMBINE(BSEMPMS SAL_BMI HIREDATE_BMI)*/ * from BSEMPMS
WHERE SAL<5000000 AND HIREDATE<SYSDATE;
11. /*+INDEX_JOIN(TABLE INDEX
Ïà¹ØÎĵµ£º
http://www.oreilly.com/catalog/artofsql £¨ÔÊ飩
http://www.oreilly.com.cn/book.php?bn=978-7-121-05834-9 (ÖÐÎÄ°æ)
Êý¾Ý¿â¼¼ÊõÊÇÆóÒµÐÅÏ¢»¯¿ª·¢µÄ»ù´¡¡£ÔÚÖÆÔìÒµÐÅÏ¢»¯ÁìÓò´ÓÒµ¶àÄ꣬×Ô¼º¶ÔÕâ¿é֪ʶȴһֱÁãËéÔÓÂÒ£¬Ó¦¸ÃÀí˳˼·£¬Îª¼Ü¹¹Éè¼ÆµÄÄ¿±ê½¨Á¢»ù´¡¡£
´ËÊé ......
¼òµ¥µØ˵£¬¾ÍÊÇ´ÓCDMÉú³ÉPDMµÄʱºò£¬releationshipÔ¼ÊøÎÞЧ£¬²»ÄÜÉú³ÉÍâ¼üÔ¼ÊøµÄ´úÂë¡£Éú³É»ùÓÚoracleµÄpdmûÎÊÌ⣬ms sql serverÓÐÎÊÌâ
ÕâÀïµÄÊÇsql server 2005
Power DesignerÊÇ15.0.0.2613
¿´Æð來ÊÇPDµÄbug,½â決辦·¨ÊÇÔÚPDM畫ÃæÖÐ點選Model->References...
會Ìø³öÒ ......
²éѯËÙ¶ÈÂýµÄÔÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ£º
¡¡¡¡1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà ......
´´½¨×éºÏ²éѯ
¿ÉÓÃUNION²Ù×÷·ûÀ´×éºÏÊýÌõSQL²éѯ¡£ÀûÓÃUNION£¬¿É¸ø³ö¶àÌõSELECTÓï¾ä£¬½«ËüÃǵĽá¹û×éºÏ³Éµ¥¸ö½á¹û¼¯¡£
16.2.1 ʹÓÃUNION
UNIONµÄʹÓúܼòµ¥¡£ËùÐè×öµÄÖ»ÊǸø³öÿÌõSELECTÓï¾ä£¬ÔÚ¸÷ÌõÓï¾äÖ®¼ä·ÅÉϹؼü×ÖUNION¡£
¾ÙÒ»¸öÀý×Ó£¬¼ÙÈçÐèÒª¼Û¸ñСÓÚµÈÓÚ5µÄËùÓÐÎïÆ·µÄÒ»¸öÁÐ±í£¬¶øÇÒ»¹Ïë°üÀ¨¹©Ó¦ÉÌ1001ºÍ1002É ......