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

ʹÓà SQL Server ʱÐèÒª¾­³£Óõ½µÄ¼¸¸öÉèÖÃÑ¡Ïî


1. SET DEADLOCK_PRIORITY
˵Ã÷£º¿ØÖÆÔÚ·¢ÉúËÀËøÇé¿öʱ»á»°µÄ·´Ó¦·½Ê½¡£Èç¹ûÁ½¸ö½ø³Ì¶¼Ëø¶¨Êý¾Ý£¬²¢ÇÒÖ±µ½ÆäËü½ø³ÌÊÍ·Å×Ô¼ºµÄËøʱ£¬Ã¿¸ö½ø³Ì²ÅÄÜÊÍ·Å×Ô¼ºµÄËø£¬¼´·¢ÉúËÀËøÇé¿ö¡£
Óï·¨£ºSET DEADLOCK_PRIORITY { LOW | NORMAL | @deadlock_var }
²ÎÊý£ºLOW  Ö¸¶¨µ±Ç°»á»°ÎªÊ×Ñ¡ËÀËøÎþÉüÆ·¡£Microsoft® SQL Server™ ×Ô¶¯»Ø¹öËÀËøÎþÉüÆ·µÄÊÂÎñ£¬²¢¸ø¿Í»§¶ËÓ¦ÓóÌÐò·µ»Ø 1205 ºÅËÀËø´íÎóÐÅÏ¢¡£
¡¡¡¡¡¡NORMAL  Ö¸¶¨»á»°·µ»Øµ½Ä¬ÈϵÄËÀËø´¦Àí·½·¨¡£
¡¡¡¡¡¡@deadlock_var ÊÇÖ¸¶¨ËÀËø´¦Àí·½·¨µÄ×Ö·û±äÁ¿¡£Èç¹ûÖ¸¶¨ LOW£¬Ôò @deadlock_var Ϊ 3£»Èç¹ûÖ¸¶¨ NORMAL£¬Ôò @deadlock_var Ϊ 6¡£
×¢ÊÍ£ºSET DEADLOCK_PRIORITY µÄÉèÖÃÊÇÔÚÖ´ÐлòÔËÐÐʱÉèÖ㬶ø²»ÊÇÔÚ·ÖÎöʱÉèÖá£
ȨÏÞ£ºSET DEADLOCK_PRIORITY ȨÏÞĬÈÏÊÚÓèËùÓÐÓû§¡£
2. SET LOCK_TIMEOUT
˵Ã÷£ºÖ¸¶¨Óï¾äµÈ´ýËøÊͷŵĺÁÃëÊý¡£
Óï·¨£ºSET LOCK_TIMEOUT timeout_period
²ÎÊý£ºtimeout_period ÊÇÔÚ Microsoft® SQL Server™ ·µ»ØËø¶¨´íÎóÇ°¾­¹ýµÄºÁÃëÊý¡£ÖµÎª -1£¨Ä¬ÈÏÖµ£©Ê±±íʾûÓг¬Ê±ÆÚÏÞ£¨¼´ÎÞÏÞÆڵȴý£©¡£
¡¡¡¡¡¡   µ±ËøµÈ´ý³¬¹ý³¬Ê±ÖµÊ±£¬½«·µ»Ø´íÎó¡£ÖµÎª 0 ʱ±íʾ¸ù±¾²»µÈ´ý£¬²¢ÇÒÒ»Óöµ½Ëø¾Í·µ»ØÐÅÏ¢¡£
×¢ÊÍ£ºÔÚÁ¬½Ó¿ªÊ¼Ê±£¬¸ÃÉèÖõÄֵΪ -1¡£ÉèÖøü¸Äºó£¬ÐÂÉèÖÃÔÚÆäÓàµÄÁ¬½Óʱ¼äÀïÒ»Ö±ÓÐЧ¡£
¡¡¡¡¡¡SET LOCK_TIMEOUT µÄÉèÖÃÊÇÔÚÖ´ÐлòÔËÐÐʱÉèÖ㬶ø²»ÊÇÔÚ·ÖÎöʱÉèÖá£
¡¡¡¡¡¡READPAST Ëø¶¨ÌáʾΪ¸Ã SET Ñ¡ÏîÌṩÁËÁíÒ»ÖÖ·½Ê½¡£
ȨÏÞ£ºSET LOCK_TIMEOUT ȨÏÞĬÈÏÊÚÓèËùÓÐÓû§¡£
ʾÀý£ºÏÂÀý½«Ëø³¬Ê±ÆÚÏÞÉèÖÃΪ 1,800 ºÁÃë¡£
¡¡¡¡¡¡SET LOCK_TIMEOUT 1800
¡¡¡¡¡¡GO
3. @@LOCK_TIMEOUT
˵Ã÷£º·µ»Øµ±Ç°»á»°µÄµ±Ç°Ëø³¬Ê±ÉèÖ㬵¥Î»ÎªºÁÃë¡£
Óï·¨£º@@LOCK_TIMEOUT
·µ»ØÀàÐÍ£ºinteger
×¢ÊÍ£ºSET LOCK_TIMEOUT ÔÊÐíÓ¦ÓóÌÐòÉèÖÃÓï¾äµÈ´ý×èÈû×ÊÔ´µÄ×ʱ¼ä¡£µ±Ò»ÌõÓï¾äÒѵȴý³¬¹ý LOCK_TIMEOUT ËùÉèÖõÄʱ¼ä£¬Ôò±»ËøסµÄÓï¾ä½«×Ô¶¯È¡Ïû£¬²¢¸øÓ¦ÓóÌÐò·µ»ØÒ»Ìõ´íÎóÐÅÏ¢¡£
¡¡¡¡¡¡ÔÚÒ»¸öÁ¬½ÓµÄ¿ªÊ¼£¬@@LOCK_TIMEOUT ·µ»ØÒ»¸ö –1Öµ¡£
ʾÀý£ºÏÂÃæµÄʾÀýÏÔʾµ±Ò»¸ö LOCK_TIMEOUT ֵδ±»ÉèÖÃʱµÄ½á¹û¼¯¡£
¡¡¡¡¡¡SELECT @@LOCK_TIMEOUT
¡¡¡¡¡¡ÏÂÃæÊǽá¹û¼¯£º
¡¡¡¡¡¡----------------
¡¡¡¡¡¡-1
¡¡¡¡¡¡ÏÂÃæµÄʾÀýÉèÖà LOCK_TIMEOUT Ϊ 1800 ºÁÃ룬Ȼºóµ÷Óà @@LOCK_TIMEOUT¡£
¡¡¡¡¡¡SET LOCK_TIMEOUT


Ïà¹ØÎĵµ£º

ASP.Net + SQL Server ´æ´¢¹ý³ÌʵÏÖ·ÖÒ³ÅÅÐò

ÎÊÌâÌá³ö:
ÔÚÓ¦ÓóÌÐòÖо­³£ÐèÒª²éѯÊý¾Ý¡£µ±²éѯ½á¹ûÊý¾ÝÁ¿±È½Ï´óµÄʱºò£¬¼ìË÷½á¹û¡¢½çÃæÏÔʾ¶¼ÐèÒª»¨·Ñ´óÁ¿µÄʱ¼ä¡£ÎªÁ˱ÜÃâÕâ¸öÎÊÌ⣬Ӧ¸Ãÿ´ÎÖ»¼ìË÷²¿·ÖÊý¾Ý£¬Ò²¾ÍÊÇʹÓó£¼ûµÄ·ÖÒ³·½Ê½À´´¦Àí¡£·ÖÒ³µÄÎÊÌâÔÚasp.netÖкÃÏñ·Ç³£¼òµ¥£¬Ö»ÒªÔÚGridViewÖÐÆôÓ÷ÖÒ³¾Í¿ÉÒÔÁË¡£ÆôÓ÷ÖÒ³ºó£¬GridView¹ØÁªÊý¾ÝÔ´¿Ø¼þ£¬ÒÀ¾É»á¼ÓÔØ ......

SQl Êý¾Ý¿âÏà¹Ø²Ù×÷

1£º
Sql server 2005ÈÕÖ¾ÎļþÌ«´ó,ʹÆä¼õСµÄ·½·¨
ÔËÐÐÏÂÃæµÄÈýÐÐ PMDataCenter  ΪÊý¾Ý¿âÃû:
backup log PMDataCenter with NO_LOG
backup log PMDataCenter with TRUNCATE_ONLY
DBCC SHRINKDATABASE(PMDataCenter) ......

SQL Union ÓëUnion AllÏê½â

1.Union
UNION Ö¸ÁîµÄÄ¿µÄÊǽ«Á½¸ö SQL Óï¾äµÄ½á¹ûºÏ²¢ÆðÀ´¡£´ÓÕâ¸ö½Ç¶ÈÀ´¿´£¬ UNION ¸ú JOIN ÓÐЩÐíÀàËÆ£¬ÒòΪÕâÁ½¸öÖ¸Á¿ÉÒÔÓɶà¸ö±í¸ñÖÐߢȡ×ÊÁÏ¡£ UNION µÄÒ»¸öÏÞÖÆÊÇÁ½¸ö SQL Óï¾äËù²úÉúµÄÀ¸Î»ÐèÒªÊÇͬÑùµÄ×ÊÁÏÖÖÀà¡£ÁíÍ⣬µ±ÎÒÃÇÓà UNIONÕâ¸öÖ¸Áîʱ£¬ÎÒÃÇÖ»»á¿´µ½²»Í¬µÄ×ÊÁÏÖµ (ÀàËÆ SELECT DISTINCT)¡£
UNION µ ......

SQLÊý¾Ý¿â±í»µÁ˵ÄÊÖ¶¯»Ö¸´·½·¨

      ½ñÌì½Óµ½¿Í»§µç»°£¬Ëµ²Ù×÷Êý¾ÝÎÞ·¨±£´æ¡£¾­¹ý·ÖÎö£¬·¢ÏÖËûµÄÊý¾Ý¿âÒѾ­ÓÐ5G¶àµÄ´óС£¬¶ø×îÖÕ·¢ÏÖÓÐÕűíµÄË÷Òý³ö´íÁË£¬ÓÃDBCC CHECKÒ²ÎÞÁ¦»ØÌì¡£
ÿ´ÎÓÃselect * from ln003082 Óï¾ä²éѯ£¬¶¼±¨ÈçÏ´íÎó£º
·þÎñÆ÷: ÏûÏ¢ 605£¬¼¶±ð 21£¬×´Ì¬ 1£¬ÐÐ 1
ÊÔͼ´ÓÊý¾Ý¿â 'ln_fl0125' ÖÐÌáÈ¡µÄÂß¼­ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ