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

SQLµ÷ÓÅ(Á¬½Ó·½Ê½)

SQLµ÷ÓÅ Ö® Á¬½Ó·½Ê½
JoinÊÇÒ»ÖÖÊÔͼ½«Á½¸ö±í½áºÏÔÚÒ»ÆðµÄν´Ê£¬Ò»´ÎÖ»ÄÜÁ¬½Ó2¸ö±í£¬±íÁ¬½ÓÒ²¿ÉÒÔ±»³ÆΪ±í¹ØÁª¡£ÔÚºóÃæµÄÐðÊöÖУ¬Ê¹ÓÔrow source”À´´úÌ攱픣¬ÒòΪʹÓÃrow source¸üÑϽ÷һЩ£¬²¢ÇÒ½«²ÎÓëÁ¬½ÓµÄ2¸örow source·Ö±ð³ÆΪrow source1ºÍrow source 2¡£Join¹ý³ÌµÄ¸÷¸ö²½Öè¾­³£ÊÇ´®ÐвÙ×÷£¬¼´Ê¹Ïà¹ØµÄrow source¿ÉÒÔ±»²¢ÐзÃÎÊ£¬¼´¿ÉÒÔ²¢ÐеĶÁÈ¡×öjoinÁ¬½ÓµÄÁ½¸örow sourceµÄÊý¾Ý£¬µ«ÊÇÔÚ½«±íÖзûºÏÏÞÖÆÌõ¼þµÄÊý¾Ý¶ÁÈëµ½ÄÚ´æÐγÉrow sourceºó£¬joinµÄÆäËü²½ÖèÒ»°ãÊÇ´®Ðеġ£ÓжàÖÖ·½·¨¿ÉÒÔ½«2¸ö±íÁ¬½ÓÆðÀ´£¬µ±È»Ã¿ÖÖ·½·¨¶¼ÓÐ×Ô¼ºµÄÓÅȱµã£¬Ã¿ÖÖÁ¬½ÓÀàÐÍÖ»ÓÐÔÚÌض¨µÄÌõ¼þϲŻᷢ»Ó³öÆä×î´óÓÅÊÆ¡£
row source(±í)Ö®¼äµÄÁ¬½Ó˳Ðò¶ÔÓÚ²éѯµÄЧÂÊÓзdz£´óµÄÓ°Ï졣ͨ¹ýÊ×ÏÈ´æÈ¡Ìض¨µÄ±í£¬¼´½«¸Ã±í×÷ΪÇý¶¯±í,ÕâÑù¿ÉÒÔÏÈÓ¦ÓÃijЩÏÞÖÆÌõ¼þ,´Ó¶øµÃµ½Ò»¸ö½ÏСµÄrow source£¬Ê¹Á¬½ÓµÄЧÂʽϸߣ¬ÕâÒ²¾ÍÊÇÎÒÃdz£ËµµÄÒªÏÈÖ´ÐÐÏÞÖÆÌõ¼þµÄÔ­Òò¡£Ò»°ãÊÇÔÚ½«±í¶ÁÈëÄÚ´æʱ£¬Ó¦ÓÃwhere×Ó¾äÖжԸñíµÄÏÞÖÆÌõ¼þ¡£
¸ù¾Ý2¸örow sourceµÄÁ¬½ÓÌõ¼þµÄÖвÙ×÷·ûµÄ²»Í¬£¬¿ÉÒÔ½«Á¬½Ó·ÖΪµÈÖµÁ¬½Ó(ÈçWHERE A.COL3 = B.COL4)¡¢·ÇµÈÖµÁ¬½Ó(WHERE A.COL3 > B.COL4)¡¢ÍâÁ¬½Ó(WHERE A.COL3 = B.COL4(+))¡£ÉÏÃæµÄ¸÷¸öÁ¬½ÓµÄÁ¬½ÓÔ­Àí¶¼»ù±¾Ò»Ñù£¬ËùÒÔΪÁ˼òµ¥Æڼ䣬ÏÂÃæÒÔµÈÖµÁ¬½ÓΪÀý½øÐнéÉÜ¡£
 
ÎÞÂÛÁ¬½Ó²Ù×÷·ûÈçºÎ£¬µäÐ͵ÄÁ¬½ÓÀàÐ͹²ÓÐ3ÖÖ£º
ÅÅÐò - - ºÏ²¢Á¬½Ó(Sort Merge Join (SMJ) )
ǶÌ×Ñ­»·(Nested Loops (NL) )
¹þÏ£Á¬½Ó(Hash Join)
ÅÅÐò - - ºÏ²¢Á¬½Ó(Sort Merge Join, SMJ)
ÄÚ²¿Á¬½Ó¹ý³Ì£º
1) Ê×ÏÈÉú³Érow source1ÐèÒªµÄÊý¾Ý£¬È»ºó¶ÔÕâЩÊý¾Ý°´ÕÕÁ¬½Ó²Ù×÷¹ØÁªÁÐ(ÈçA.col3)½øÐÐÅÅÐò¡£
2) ËæºóÉú³Érow source2ÐèÒªµÄÊý¾Ý£¬È»ºó¶ÔÕâЩÊý¾Ý°´ÕÕÓësort source1¶ÔÓ¦µÄÁ¬½Ó²Ù×÷¹ØÁªÁÐ
(ÈçB.col4)½øÐÐÅÅÐò¡£
3) ×îºóÁ½±ßÒÑÅÅÐòµÄÐб»·ÅÔÚÒ»ÆðÖ´Ðкϲ¢²Ù×÷£¬¼´½«2¸örow source°´ÕÕÁ¬½ÓÌõ¼þÁ¬½ÓÆðÀ´
ÏÂÃæÊÇÁ¬½Ó²½ÖèµÄͼÐαíʾ£º
                             MERGE
                            /              \
              


Ïà¹ØÎĵµ£º

VB+SQL 2000 ʵÏÖÊý¾Ý¿âµÄ±¸·ÝºÍ»Ö¸´

 
'*************************************************************************
'**Ä£ ¿é Ãû£ºfBackupDatabase_a
'**Ãè    Êö£º±¸·ÝÊý¾Ý¿â,·µ»Ø³ö´íÐÅÏ¢,Õý³£»Ö¸´,·µ»Ø""
'**µ÷    ÓãºfBackupDatabase_a "±¸·ÝÎļþÃû","Êý¾Ý¿ ......

SQL ServerÖÐDATAADDºÍDATADIFFµÄÓ÷¨

ͨ³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆںͼÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£´ó²¿·ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡ÔÚÕâƪÎÄÕÂÀÎÒ½«½ÌÄãÈçºÎʹÓÃDATEADDºÍDATEDIFFº¯ÊýÀ´¼ÆËã³öÔÚÄãµÄ³ÌÐòÖпÉÄÜÄ ......

sqlÓï¾ä

/*»ñÈ¡Öظ´¼Ç¼ÖнÏСµÄÄǸöID*/ create table tmp_Repeat as  select  min(id) as id from poi group by idcode having count(*) >1; /*±¸·Ýɾ³ýµÄÊý¾Ý*/ select * from poi where id in (select id from tmp_repeat) /*ɾ³ýÖظ´¼Ç¼ÖÐID½ÏСµÄÄÇÌõ
select replace('°¢¹ðÊǸöºÃº¢×Ó','°¢¹ð','СÏÍ') from du ......

SQL server 2000 ÈçºÎÅжÏÁÙʱ±íÊÇ·ñ´æÔÚ


 
 
1.ÅжÏÒ»¸öÁÙʱ±íÊÇ·ñ´æÔÚ
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U')
   drop table #tempcitys
×¢ÒâtempdbºóÃæÊÇÁ½¸ö. ²»ÊÇÒ»¸öµÄ
---ÁÙʱ±í
if exists(select * from tempdb..sysobjects where name like &lsqu ......

½â¾öMS SQL Server 2005 ÎÞ·¨Ô¶³ÌÁ¬½ÓÎÊÌâ

ÔÚWindows 2003 sp1·þÎñÆ÷ÉÏȱʡ°²×° MS SQL Server 2005 ¼òÌåÖÐÎÄÆóÒµ°æ£¬ÔÚÁ¬½Ó·þÎñÆ÷ʱÏÔʾ“²»ÔÊÐíÔ¶³ÌÁ¬½Ó”¡£
¾ßÌåÏÔʾÈçÏ£º(xxxxxsqlΪ·þÎñÆ÷Ãû£¬ÔÚ±¾µØ²Ù×÷)
C:\Documents and Settings\Administrator>sqlcmd -S xxxxxsql
HResult 0x2£¬¼¶±ð 16£¬×´Ì¬ 1
ÃüÃû¹ÜµÀÌṩ³ÌÐò: ÎÞ·¨´ò¿ªÓë SQL Server ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ