Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL×¢ÊÍÓÅ»¯

1. /*+ALL_ROWS*/
   ±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
   ÀýÈç:
   SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='CCBZZP';
2. /*+FIRST_ROWS*/
   ±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÏìӦʱ¼ä,ʹ×ÊÔ´ÏûºÄ×îС»¯.
   ÀýÈç:
   SELECT /*+FIRST_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE    EMP_NO='CCBZZP';
3. /*+CHOOSE*/
   ±íÃ÷Èç¹ûÊý¾Ý×ÖµäÖÐÓзÃÎʱíµÄͳ¼ÆÐÅÏ¢,½«»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑµÄÍÌÍÂÁ¿;
   ±íÃ÷Èç¹ûÊý¾Ý×ÖµäÖÐûÓзÃÎʱíµÄͳ¼ÆÐÅÏ¢,½«»ùÓÚ¹æÔò¿ªÏúµÄÓÅ»¯·½·¨;
   ÀýÈç:
   SELECT /*+CHOOSE*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='CCBZZP';
4. /*+RULE*/
   ±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¹æÔòµÄÓÅ»¯·½·¨.
   ÀýÈç:
   SELECT /*+ RULE */ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='CCBZZP';  
5. /*+FULL(TABLE)*/
   ±íÃ÷¶Ô±íÑ¡ÔñÈ«¾ÖɨÃèµÄ·½·¨.
   ÀýÈç:
   SELECT /*+FULL(A)*/ EMP_NO,EMP_NAM from BSEMPMS A WHERE EMP_NO='CCBZZP';
6. /*+ROWID(TABLE)*/
   ÌáʾÃ÷È·±íÃ÷¶ÔÖ¸¶¨±í¸ù¾ÝROWID½øÐзÃÎÊ.
   ÀýÈç:
   SELECT /*+ROWID(BSEMPMS)*/ * from BSEMPMS WHERE ROWID>='AAAAAAAAAAAAAA'
   AND EMP_NO='CCBZZP';
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_BSE


Ïà¹ØÎĵµ£º

35Ìõ»ù±¾SQLÓï¾ä

 1¡¢²éÕÒÔ±¹¤µÄ±àºÅ¡¢ÐÕÃû¡¢²¿ÃźͳöÉúÈÕÆÚ£¬Èç¹û³öÉúÈÕÆÚΪ¿ÕÖµ£¬ÏÔʾÈÕÆÚ²»Ïê,²¢°´²¿ÃÅÅÅÐòÊä³ö,ÈÕÆÚ¸ñʽΪyyyy-mm-dd¡£
select
emp_no,emp_name,dept,isnull(convert(char(10),birthday,120),'ÈÕÆÚ²»Ïê') birthday
from employee
order by dept
 
¡¡¡¡
2¡¢²éÕÒÓëÓ÷×ÔÇ¿ÔÚͬһ¸öµ¥Î»µÄÔ±¹¤ÐÕÃû¡¢ÐÔ±ð¡ ......

SQL ServerÈÕÖ¾Çå¿Õ·½·¨

תÔØ£ºhttp://blog.csdn.net/cnming/archive/2009/03/11/3979290.aspx
ÔÚ²éѯ·ÖÎöÆ÷ÖÐ˳ÐòÖ´ÐÐÒÔÏÂÈý²½£¬ÆäÖР  databasename   ΪÄãµÄÊý¾Ý¿âÎļþÃû
1.Çå¿ÕÈÕÖ¾£ºDUMP   TRANSACTION   databasename   WITH   NO_LOG  
2.½Ø¶ÏÊÂÎñÈÕÖ¾£ºBACKUP ......

mysqlµÄsql_mode½éÉÜ

mysql¿ÉÒÔÔËÐÐÔÚ²»Í¬sql modeģʽÏÂÃ棬sql modeģʽ¶¨ÒåÁËmysqlÓ¦¸ÃÖ§³ÖµÄsqlÓï·¨£¬Êý¾ÝУÑéµÈ£¡
 
²é¿´Ä¬ÈϵÄsql modeģʽ£º
select @@sql_mode;
ÎÒµÄÊý¾Ý¿âÊÇ£º
STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
ÔÚ´ËģʽÏÂÃ棬Èç¹û²åÈëµÄÊý¾ÝµÄ³¤¶È´óÓÚ¶¨ÒåµÄ³¤¶È£¬ÄÇô¾Í»á±¨´í£¡
  ......

Sql ServerÊý¾Ý¿â´¥·¢Æ÷ʵÀý½²½â


´¥·¢Æ÷
     ¶¨Ò壺 ºÎΪ´¥·¢Æ÷£¿ÔÚSQL ServerÀïÃæÒ²¾ÍÊǶÔijһ¸ö±íµÄÒ»¶¨µÄ²Ù×÷£¬´¥·¢Ä³ÖÖÌõ¼þ£¬´Ó¶øÖ´ÐеÄÒ»¶Î³ÌÐò¡£´¥·¢Æ÷ÊÇÒ»¸öÌØÊâµÄ´æ´¢¹ý³Ì¡£
     ³£¼ûµÄ´¥·¢Æ÷ÓÐÈýÖÖ£º·Ö±ðÓ¦ÓÃÓÚInsert , Update , Delete Ê¼þ¡£(SQL& ......

Ò»¸öÌâÄ¿Éæ¼°µ½µÄ50¸öSqlÓï¾ä

Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“001”¿Î³Ì±È“002”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ£»
  select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
  fr ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ