SQLÓÅ»¯¹¤¾ßLecco SQL Expert For Oracle
ÔÚ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 
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÎÒÃÇÓÐʱºò¿ÉÄÜ»áÐèÒªÐ޸ıí¸ñÖеÄ×ÊÁÏ¡£ÔÚÕâ¸öʱºò£¬ÎÒÃǾÍÐèÒªÓõ½ UPDATE Ö¸Áî¡£Õâ¸öÖ¸ÁîµÄÓï·¨ÊÇ£º
UPDATE "±í¸ñÃû"
SET "À¸Î»1" = [ÐÂÖµ]
WHERE {Ìõ¼þ}
×îÈÝÒ×Á˽âÕâ¸öÓï·¨µÄ·½Ê½ÊÇ͸¹ýÒ»¸öÀý×Ó¡£¼ÙÉèÎÒÃÇÓÐÒÔϵıí¸ñ£º
Store_Information ±í¸ñ
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1 ......
Õ⼸Ììд´æ´¢¹ý³Ì£¬Ã¿Ì춨ʱ²îÒ챸·Ý£¬²¢×Ô¶¯·¢Óʼþ¸ø²Ù×÷ÈËÐÞ¸ÄÒªÐ޸ĵÄÄÚÈÝ¡£ ÔÚÕâÀïд³ösql serverµÄ´úÀí²Ù×÷£¬½ÓÏÂÀ´°ÑдµÄ·¢ÓʼþµÄ´æ´¢¹ý³ÌÒ²·¢³ö¡£´ó¼Ò×÷¸ö²Î¿¼¡¡¡¡
Èç¹ûÔÚsql server ÀïÐèÒª¶¨Ê±»òÕßÿ¸ôÒ»¶Îʱ¼äÖ´ÐÐij¸ö´æ´¢¹ý³Ì»ò3200×Ö·ûÒÔÄÚµÄsqlÓï¾äʱ,¿ÉÒÔÓùÜÀí->sql server´úÀí->×÷ÒµÀ´ÊµÏÖ¡£
  ......
·½·¨Ò»
µÚÒ»²½£ºµÇÈësql/plus Ö´ÐÐÃüÁÎÞÏȺó˳Ðò£©
set time on; (˵Ã÷£º´ò¿ªÊ±¼äÏÔʾ£©
set autotrace on; (˵Ã÷£º´ò¿ª×Ô¶¯·ÖÎöͳ¼Æ£¬²¢ÏÔʾSQLÓï¾äµÄÔËÐнá¹û£©
set autotrace traceonly; (˵à ......
1.·ÖÎöϵͳÈÕÖ¾£¬Ò»ÐÐÒ»Ðп´×ÅʵÔÚÀÛÈË£¬ºÜ¶àÎÞ¹ØÈÕÖ¾£¬ÄܹýÂËϾͺÃÁË¡£Îı¾¹¤¾ß¹¦ÄÜʵÔÚÓÐÏÞ£¬ÓÚÊǺõ£¬½«windowsϵͳÈÕÖ¾µ¼Èësql serverÖУ¬Ö±½ÓsqlÖ®……¡£ÊµÑéÁ˼¸°Ñ£¬×îºÃµÄÊÇ£¬Ö±½Ó½«ÏµÍ³ÈÕÖ¾µ¼³öΪÎı¾µÄ£¬Ö±½Ótab·Ö¸îµÄ£¬µ¼ÈësqlµÄʱºò£º
н¨Êý¾Ý¿â->µ¼ÈëÊý¾Ý->ÏÂÒ»²½->Êý¾ÝÔ´Ñ¡ÔñÎı¾Îļþ- ......