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

SQL Server 2008 ¸´ÖÆ ·ÖÇøSWITCHÇåÀíÊý¾Ý

SQL Server 2008 ¸´ÖÆ ·ÖÇøSWITCHÇåÀíÊý¾Ý
 ³¡¾°£º
ijÖÖÌØ¶¨ÒµÎñÏ£¬ÎÒÃǵIJ¿·ÖÒµÎñÊý¾Ý¿ÉÄÜÖ»»á±£Áô±È½Ï¶ÌµÄʱ¼ä£¬ÓÃÀ´×öÁÙʱ´¦Àí¡£ÒòΪ¿¼ÂǸ߿ÉÓõÄÌØÐÔ£¬¿ÉÄÜ»áÀûÓÃ
SQL ServerµÄ¸´ÖÆ×é¼þ¸´ÖÆÕâÖÖÊý¾Ýµ½ÁíÍâµÄ ÀàËÆÇ°¶Ë£¬²éѯÖÐÐĵÈÊý¾Ý¿â·þÎñÆ÷£¬´´½¨Ò»¸öÈßÓั±¾¡£¸´ÖÆ×é¼þ±ê¼ÇÊÂÎñÈÕÖ¾£¬×·×ÙËùÓеÄUpdate£¬Insert£¬Delete²Ù×÷¡£¿ÉÊÇÈç¹û²»¶¨ÆÚÇåÀíÕâÖÖ±í£¬ÄÇôÔÚÒ»¸ö¿ìËÙÔö³¤µÄ»·¾³Ï£¬±í±äµÄÓ·Öײ»¿°£¬²»½ö½öÀË·Ñ´ÅÅ̿ռ䣬¶øÇÒ¸øÐÔÄÜ´øÀ´Á˸ºÃæÓ°Ïì¡£
È磺
AÁÙʱÊý¾ÝÖÐÐÄ   ---ͬ²½-->B ²éѯ/ÆäËûÒµÎñÖÐÐÄ£¬¸±±¾
±£Ö¤A²»¿ÉÓõÄʱºò£¬BµÄÒµÎñ²»ÒÀÀµÓÚA·þÎñÆ÷£¬ÀûÓÃAͬ²½¹ýÀ´µÄÊý¾ÝB×Ô¼ºÖ±½Ó´¦Àí¡£
³£¼ûµÄ½â¾ö·½°¸£º
                Ò»¡¢ºÜ¼òµ¥µÄ£¬ÎÒÃÇ¿ÉÒÔÏëµ½£¬½¨Á¢Ò»¸öÇåÀíJob
£¬¸ù¾ÝÈÕÆÚ±êʶ£¬È·¶¨É¾³ýµÄ·¶Î§²»³öÒ»µã´íÎ󣬱ÈÈçÎÒÿÌìµÄÍíÉÏ12£º00ÒÔºóÇåÀí×òÌìµÄÊý¾Ý£¬ÄÇô¿ÉÄܻṹ½¨ÕâÑùµÄ²éѯ£¨ÅóÓÑÃÇ£¬Ò²Ðí»á˵ʹÓÃTRUNCATE
£¬×¼Ê±µÄ12£º00À´TRUNCATEµô£¬²»¹ýºÜ²»ÐÒµÄÊÇ£¬SQL
Server ¸´ÖÆÊÇÀûÓÃÈÕÖ¾±ê¼ÇµÄ·½Ê½À´Í¬²½Êý¾Ý£¬¶øTRUNCATEÓï¾ä²»»á±»ÈÕÖ¾±ê¼Ç£¬ËùÒÔTRUNCATEÓï¾äÔÚ¸´ÖƱíÖÐÊDZ»½ûÓõģ©
DELETE from dbo.t WHERE complete_time >=
'2010-05-04' AND
complete_time < '2010-05-05'
À´É¾³ý5ÔÂ4ºÅµÄËùÓÐÊý¾Ý£¬¿ÉÄÜÉÏÒÚÒ²¿ÉÄܸü¶à¡£
ÓÅ»¯·½°¸£ºÒòΪ¿¼Âǵ½´æÔÚ´øÁ¿µÄ¸üРɾ³ý ºÍ²åÈë²Ù×÷£¬ËùÒÔÊ×ÏȽ²Êý¾Ý¿âÉèÖóÉSIMPLE»Ö¸´Ä£Ê½£¬ÒÔ×îС»¯ÈÕÖ¾·½Ê½¡£
ÓÉÓÚDELETEµ¥¸öÓï¾äÊÇÒ»¸öÊÂÎñÐÔµÄÓï¾ä£¬ÒªÃ´È«²¿³É¹¦£¬ÒªÃ´È«²¿Ê§°Ü¡£ÄÇô¿ÉÏëÈç¹ûɾ³ýµÄÊÇÒÚ¼¶±ðµÄÊý¾Ý£¬ÄÇôÈÕÖ¾Ôö³¤,IO¸ººÉ·Ç³£µÄ´ó¡£
ËùÒÔ ¿ÉÄÜÓÅ»¯DELETE
²Ù×÷£º
WHILE 1=1
BEGIN
    DELETE TOP(5000) from dbo.t
    WHERE complete_time >= '2010-05-04' AND complete_time <
'2010-05-05'
    IF @@ROWCOUNT<5000
         BREAK;
END
½«É¾³ý²Ù×÷£¬Ëõ¶Ì³Éÿ5000ÐÐÒ»ÅúµÄÊý¾ÝÀ´´¦Àí¡£
ȱµã£ºÒòΪ´æÔÚ¸´ÖÆ£¬ÄÇôºÜÏÔÈ»£¬ÀË·ÑÁ˼«¶àµÄ´ø¿í£¬ÌرðÔÚInternetÕâÖÖ»·¾³Ï£¬ÀûÓÃVPNµÄÁ¬½Ó£¬ÓÈÆäÀË·Ñ¡£VPN´ø¿íÊ®·ÖµÄÃìС¡£ÔÙÕߣ¬ÔÚ½øÐÐÒÚ¼¶µÄDELETE£¬Ê±¼äºÄ·ÑÒ²ÊǷdz£¿Ö²ÀµÄ£¬¶øÇÒDELETE¹ý³ÌÖУ¬ÓÉÓÚ´æÔÚRange-X
·¶Î§ÅÅËûËø£¬Ðí¶à¿ª·¢ÈËÔ±


Ïà¹ØÎĵµ£º

sql»ù±¾Óï¾ä

/*********************************************************/
Ŀ¼Çåµ¥CONTEXT LIST
/*********************************************************/
1.Êý¾Ý¿âDataBase
1.1Êý¾Ý¿â½¨Á¢/ɾ³ýcreate/drop database
1.2Êý¾Ý¿â±¸·ÝÓë»Ö¸´backup/restore database
/***************************************************** ......

SQLÓï¾äÖÐDateDiffº¯Êý˵Ã÷

º¯Êý¼ò½é:¡¡¡¡
     ·µ»Ø Variant (Long) µÄÖµ£¬±íʾÁ½¸öÖ¸¶¨ÈÕÆÚ¼äµÄʱ¼ä¼ä¸ôÊýÄ¿¡£
º¯ÊýÓï·¨:
¡¡¡¡DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
DateDiff º¯ÊýÓï·¨ÖÐÓÐÏÂÁÐÃüÃû²ÎÊý£º
¡¡¡¡interval ±ØÒª¡£×Ö·û´®±í´ïʽ£¬±íʾÓÃÀ´¼ÆËãdate1 ºÍ date2 µÄʱ¼ä²îµÄʱ¼ä¼ ......

sql server 2005 ѧϰ±Ê¼Ç

µÚÒ»Õ£ºÐÅÏ¢Ìåϵ½á¹¹Ô­Ôò
¸ù¾ÝÒÔÏÂ7¸öÏ໥ÒÀÀµµÄÊý¾Ý´æ´¢Ä¿±êÉè¼ÆºÍÆÀ¹ÀÈκÎÊý¾Ý´æ´¢£º
l  ¼òµ¥ÐÔ£»
l  ÓÐÓÃÐÔ
l  Êý¾ÝÍêÕûÐÔ
l  ÐÔÄÜ
l  ¿ÉÓÃÐÔ
l  ¿ÉÀ©Õ¹ÐÔ
l  °²È«ÐÔ
 
¼Ü¹¹Éè¼ÆÔ­Ôò
l  ±ÜÃâ¹ýÓÚ¸´ÔÓ
l  ¾«ÐÄÌôÑ¡¼ü
l  Ê÷Á¢¿ÉÑ¡Êý¾Ý
l  ÊµÏ ......

ÅäÖà SQL Server 2005 Ô¶³Ìµ÷ÊÔ´æ´¢¹ý³Ì

ÎÊÌâ:
    Äú¹¤×÷µÄ±¾»ú×°ÓÐVisual Studio 2005£¬¾ÖÓòÍøÖÐÓÐһ̨SQL Server 2005Êý¾Ý¿â·þÎñÆ÷£¬ÄãÏëͨ¹ý±¾»úÔ¶³Ìµ÷ÊÔSQL Server 2005·þÎñÆ÷ÉϵĴ洢¹ý³Ì¡£µ«ÊDz»ÖªµÀÈçºÎÅäÖûòÆôÓÃÔ¶³Ìµ÷ÊÔ£¿Ï£ÍûÕâÆªÎÄÕ¶ÔÄúÓÐÓ᣶ÔÓÚÊý¾Ý¿âºÍVisual StudioÔÚͬһ»úÆ÷µÄ´æ´¢¹ý³Ìµ÷ÊÔ£¬Ô°×ÓÀïÒѾ­ÓÐһƪÒë×÷˵µÄºÜºÃÁË£¬¿ ......

¼¸¸ö³£Óõģ¬¶Ô±íµÄijһÁнøÐвÙ×÷µÄSQLÃüÁî

ÊÊÓãºORACLE
 ÐÞ¸ÄÁÐÃû
          alter table xxx rename column aaa to bbb;
ɾ³ýÒ»ÁÐ
          alter table xxx drop column aaa;
Ôö¼ÓÒ»ÁÐ
          alter ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ