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 ËùÉèÖõÄʱ¼ä£¬Ôò±»ËøסµÄÓï¾ä½«×Ô¶¯È¡Ïû£¬²¢¸øÓ¦ÓóÌÐò·µ»ØÒ»Ìõ´íÎóÐÅÏ¢¡£
¡¡¡¡¡¡ÔÚÒ»¸öÁ¬½ÓµÄ¿ªÊ
Ïà¹ØÎĵµ£º
Oracle SQL(partI)
Data manipulation language(DML): select, insert, update, delete, merge.
Data definition language(DDL): create, alter, drop, rename, truncate, comment
Data control language(DCL): grant, revoke
Transaction control: commit, rollback, savepoint
Arithmetic Expressions:
+, -, *, / ......
--> Title : SQL ServerϵͳÊÓͼ
--> Author : wufeng4552
--> Date : 2009-10-28
Ŀ¼ÊÓͼ
Ŀ¼ÊÓͼ·µ»Ø SQL Server Êý¾Ý¿âÒýÇæʹÓõÄÐÅÏ¢¡£½¨ÒéÄúʹÓÃĿ¼ÊÓͼÕâÒ»×î³£ÓõÄĿ¼ԪÊý¾Ý½çÃ棬Ëü¿ÉΪÄúÌṩ×îÓÐЧµÄ·½·¨À´»ñÈ¡¡¢×ª»»²¢ÏÔʾ´ËÐÅÏ¢µÄ×Ô¶¨ÒåÐÎʽ¡£ËùÓÐÓû§¿ÉÓÃĿ¼Ԫ ......
WAITFOR
Ö¸¶¨´¥·¢Óï¾ä¿é¡¢´æ´¢¹ý³Ì»òÊÂÎñÖ´ÐеÄʱ¼ä¡¢Ê±¼ä¼ä¸ô»òʼþ¡£
Óï·¨
WAITFOR { DELAY 'time' | TIME
'time' }
²ÎÊý
DELAY
ָʾ Microsoft® SQL Server™ Ò»Ö±µÈµ½Ö¸¶¨µÄʱ¼ä¹ýÈ¥£¬×¿É´ï 24 Сʱ¡£
'time'
ÒªµÈ´ýµÄʱ¼ä¡£¿ÉÒÔ°´ datetime Êý¾Ý¿É½ÓÊܵĸñʽָ¶¨
time£¬Ò²¿ÉÒÔÓþֲ¿±äÁ¿Ö¸¶ ......
ÆÕͨMySQLÔËÐУ¬Êý¾ÝÁ¿ºÍ·ÃÎÊÁ¿²»´óµÄ»°£¬ÊÇ×ã¹»¿ìµÄ£¬µ«Êǵ±Êý¾ÝÁ¿ºÍ·ÃÎÊÁ¿¾çÔöµÄʱºò£¬ÄÇô¾Í»áÃ÷ÏÔ·¢ÏÖMySQLºÜÂý£¬ÉõÖÁdownµô£¬ÄÇô¾ÍÒª¿¼ÂÇÓÅ»¯ÎÒÃǵÄMySQLÁË¡£
ÓÅ»¯ÎÞ·ÇÊÇ´ÓÈý¸ö½Ç¶ÈÈëÊÖ£º
µÚÒ»¸öÊÇ´ÓÓ²¼þ£¬Ôö¼ÓÓ²¼þ£¬Ôö¼Ó·þÎñÆ÷
µÚ¶þ¸ö¾ÍÊǶÔÎÒÃǵÄMySQL·þÎñÆ÷½øÐÐÓÅ»¯£¬Ôö¼Ó»º´æ´óС£¬¿ª¶à¶Ë¿Ú£¬¶Áд·Ö¿ª
µÚÈý¸ö ......
---¸½¼ÓÊý¾Ý¿â
sp_attach_db 'Êý¾Ý¿âÃû','Êý¾Ý¿âȫ·¾¶','Êý¾Ý¿âÈÕ־ȫ·¾¶'
---²é¿´Êý¾Ý¿âÂß¼ÎļþÃû
RESTORE FILELISTONLY from disk = '±¸·ÝÎļþ'
---»¹ÔÊý¾Ý¿â
restore database hzrb from disk = '±¸·ÝÎļþ'
with move 'Ö÷Âß¼Ãû' to '´æ·Åmdf·¾¶' ......