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

SQLÓαê¿ìËÙÉÏÊÖ

ÎÊÌâÃèÊö£ºÓÐÒÔÏÂ2ÕÅ±í£¬
      
                            ±íA
      
                            ±íB
       ÏÖÔÚÏ£ÍûµÃµ½ÕâÑùµÄÊý¾Ý±íAÀïµÄO_Saloary¼ÓÉϱíBµÄA_SalaryÊǵ±Ç°µÄ×ܹ¤×Ê£¬²¢¸üе½±íA¡£
       Äã¿ÉÒÔÓÃÊÓͼÀ´£¬±íÁ¬½ÓϾͿÉÒÔ¡£
       ÏÖÔÚÎÒÃÇ¿¼ÂÇÏÂÈÃSQL×Ô¼ºÀ´´¦Àí£¬Óαê¾ÍÊǺܺõķ½·¨¡£
       
      Ô­Àí£ºÓαê¾ÍÊÇ°ÑÊý¾Ý°´ÕÕÖ¸¶¨ÒªÇóÌáÈ¡³öÏàÓ¦µÄÊý¾Ý¼¯£¬È»ºóÖðÌõ½øÐÐÊý¾Ý´¦Àí¡£
      1.1ÓαêµÄ¸ÅÄî
       Óαê(Cursor)ËüʹÓû§¿ÉÖðÐзÃÎÊÓÉSQL Server·µ»ØµÄ½á¹û¼¯¡£Ê¹ÓÃÓαê(cursor)µÄÒ»¸öÖ÷ÒªµÄÔ­Òò¾ÍÊǰѼ¯ºÏ²Ù×÷ת»»³Éµ¥¸ö¼Ç¼´¦Àí·½Ê½¡£ÓÃSQLÓïÑÔ´ÓÊý¾Ý¿âÖмìË÷Êý¾Ýºó£¬½á¹û·ÅÔÚÄÚ´æµÄÒ»¿éÇøÓòÖУ¬ÇÒ½á¹ûÍùÍùÊÇÒ»¸öº¬Óжà¸ö¼Ç¼µÄ¼¯ºÏ¡£Óαê»úÖÆÔÊÐíÓû§ÔÚSQL serverÄÚÖðÐеطÃÎÊÕâЩ¼Ç¼£¬°´ÕÕÓû§×Ô¼ºµÄÒâÔ¸À´ÏÔʾºÍ´¦ÀíÕâЩ¼Ç¼¡£
       1.2 ÓαêµÄÓŵã
      ´ÓÓα궨Òå¿ÉÒԵõ½ÓαêµÄÈçÏÂÓŵ㣬ÕâЩÓŵãʹÓαêÔÚʵ¼ÊÓ¦ÓÃÖз¢»ÓÁËÖØÒª×÷Óãº
        1£©ÔÊÐí³ÌÐò¶ÔÓɲéѯÓï¾äselect·µ»ØµÄÐм¯ºÏÖеÄÿһÐÐÖ´ÐÐÏàͬ»ò²»Í¬µÄ²Ù×÷£¬¶ø²»ÊǶÔÕû¸öÐм¯ºÏÖ´ÐÐͬһ¸ö²Ù×÷¡£
        2£©Ìṩ¶Ô»ùÓÚÓαêλÖõıíÖеÄÐнøÐÐɾ³ýºÍ¸üеÄÄÜÁ¦¡£
        3£©Óαêʵ¼ÊÉÏ×÷ΪÃæÏò¼¯ºÏµÄÊý¾Ý¿â¹ÜÀíϵͳ£¨RDBMS£©ºÍÃæÏòÐеijÌÐòÉè¼ÆÖ®¼äµÄÇÅÁº£¬Ê¹ÕâÁ½ÖÖ´¦Àí·½Ê½Í¨¹ýÓα깵ͨÆðÀ´¡£
       1.3 ÓαêµÄʹÓÃ
½²ÁËÕâ¸ö¶àÓαêµÄÓŵ㣬ÏÖÔÚÎÒÃǾÍÇ××ÔÀ´½Ò¿ªÓαêµÄÉñÃصÄÃæÉ´¡£
ʹÓÃÓαêµÄ˳Ðò£º ÉùÃûÓαꡢ´ò¿ªÓαꡢ¶ÁÈ¡Êý¾Ý¡¢¹


Ïà¹ØÎĵµ£º

SQL ServerÖ®×é¼þ»®·Ö

      ´Ó²»Í¬µÄ½Ç¶È£¬ÎÒÃÇ¿ÉÒÔ°ÑSQL ServerÊý¾Ýƽ̨»®·ÖΪ¶à¸ö×é¼þ¡£ÎÒÃÇÏÂÃæ°´ÕÕSQL Server Internal Teamͨ³£µÄ»®·ÖÔ­Ôò£¬°ÑSQL ServerÊý¾Ýƽ̨»®·ÖΪÈçÏ£º
SSAS: SQL Server Analysis Service¡£Ö÷ÒªÓÃÀ´×ö·ÖÎöÓ㬱ÈÈçCube£¬¿ÉÒÔ´Ó²»Í¬µÄ½Ç¶ÈÉóÊÓÊý¾Ý¡£
SSIS: SQL Server Integration Servi ......

SQL ×Ö·û´®²ð·Ö

       ÓÐÕâÑùÒ»¸ö×Ö·û´®(ÖÐ,¹ú,ÖÐ,ÈËÃñ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú)
´¦Àí¹ýÖ®ºó±ä³É(ÖÐ,¹ú,ÈËÃñ,ÏÖ´ú¹¤Òµ»¯½ø³Ì)
 
        ÒÔÏÂÊÇÎҵķ½·¨,ÓÐʲô²»¶ÔµÄµØ·½»¹Çë¸÷λָµã
 ------------------ɾ³ýÖظ´µÄ×Ö·û
 declare
@v1 nvarchar
......

¼à¿ØÊý¾Ý¿âÐÔÄܵÄSQL»ã×Ü

¼à¿ØÊý¾Ý¿âÐÔÄܵÄSQL»ã×Ü ¡¾http://hi.baidu.com/g%5Fliying/blog/item/89711cfc27b82ff4fc037f80.html¡¿
1. ¼à¿ØÊÂÀýµÄµÈ´ý
select event,sum(decode(wait_Time,0,0,1)) "Prev",
sum(decode(wait_Time,0,1,0)) "Curr",count(*) "Tot"
from v$session_Wait
group by event order by 4;
2. »Ø¹ö¶ÎµÄÕùÓÃÇé¿ö
se ......

SQLÓï¾ä£º°Ñͳ¼Æ½á¹û°´ÕÕÌض¨µÄÁÐֵת»»³É¶àÁÐ

ÒªÇ󣺲éѯÿ¸öÀÏʦËù´ø±ÏÒµÉè¼ÆµÄ»ã×ÜÇé¿ö£¬±ÏÒµÉè¼ÆѧÉú·Ö±¾¿Æ¡¢×¨¿Æ£¬ÔºÍâ¡¢ÔºÄÚ£¬ÒªÇóµÃµ½µÄ½á¹ûÐÎʽÈçÏ£º
½ÌʦÃû ÔºÄÚ±¾¿Æ Ô°ÄÚר¿Æ ÔºÍâ±¾¿Æ ÔºÍâר¿Æ ºÏ¼Æ
Ïà¹ØµÄ±íÓУºÑ§Éú±í£¨°üº¬Ñ§Éú²ã´Î£©¡¢½Ìʦ±í£¨½ÌʦÃû£©¡¢Ñ§Éú¿ÎÌâ±í£¨Ñ§Éú½Ìʦ¶ÔÓ¦¹ØϵÒÔ¼°ÔºÄÚÔºÍâÐÅÏ¢£©¡£
SQLÓï¾äÈçÏ£º
select
    ......

SQL×Ö·û´®²Ù×÷º¯Êý´óÈ«

selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'ÔÆ',×Ö¶Î1£©=1;
×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´®º ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ