SQLº£Á¿Êý¾Ý²éѯµÄÓÅ»¯ÊÖ¶Î
Ò»¡¢ÒòÇéÖÆÒË£¬½¨Á¢“Êʵ±”µÄË÷Òý
½¨Á¢“Êʵ±”µÄË÷ÒýÊÇʵÏÖ²éѯÓÅ»¯µÄÊ×ҪǰÌá¡£
Ë÷Òý£¨index£©Êdzý±íÖ®ÍâÁíÒ»ÖØÒªµÄ¡¢Óû§¶¨ÒåµÄ´æ´¢ÔÚÎïÀí½éÖÊÉϵÄÊý¾Ý½á¹¹¡£µ±¸ù¾ÝË÷ÒýÂëµÄÖµËÑË÷Êý¾Ýʱ£¬Ë÷ÒýÌṩÁ˶ÔÊý¾ÝµÄ¿ìËÙ·ÃÎÊ¡£ÊÂʵÉÏ£¬Ã»ÓÐË÷Òý,Êý¾Ý¿âÒ²Äܸù¾ÝSELECTÓï¾ä³É¹¦µØ¼ìË÷µ½½á¹û£¬µ«Ëæ×űí±äµÃÔ½À´Ô½´ó£¬Ê¹ÓÓÊʵ±”µÄË÷ÒýµÄЧ¹û¾ÍÔ½À´Ô½Ã÷ÏÔ¡£×¢Ò⣬ÔÚÕâ¾ä»°ÖУ¬ÎÒÃÇÓÃÁË“Êʵ±”Õâ¸ö´Ê£¬ÕâÊÇÒòΪ£¬Èç¹ûʹÓÃË÷Òýʱ²»ÈÏÕ濼ÂÇÆäʵÏÖ¹ý³Ì£¬Ë÷Òý¼È¿ÉÒÔÌá¸ßÒ²»áÆÆ»µÊý¾Ý¿âµÄ¹¤×÷ÐÔÄÜ¡£
£¨Ò»£©ÉîÈëdz³öÀí½âË÷Òý½á¹¹
ʵ¼ÊÉÏ£¬Äú¿ÉÒÔ°ÑË÷ÒýÀí½âΪһÖÖÌØÊâµÄĿ¼¡£Î¢ÈíµÄSQL SERVERÌṩÁËÁ½ÖÖË÷Òý£º¾Û¼¯Ë÷Òý£¨clustered index£¬Ò²³Æ¾ÛÀàË÷Òý¡¢´Ø¼¯Ë÷Òý£©ºÍ·Ç¾Û¼¯Ë÷Òý£¨nonclustered index£¬Ò²³Æ·Ç¾ÛÀàË÷Òý¡¢·Ç´Ø¼¯Ë÷Òý£©¡£ÏÂÃ棬ÎÒÃǾÙÀýÀ´ËµÃ÷һϾۼ¯Ë÷ÒýºÍ·Ç¾Û¼¯Ë÷ÒýµÄÇø±ð£º
Æäʵ£¬ÎÒÃǵĺºÓï×ÖµäµÄÕýÎı¾Éí¾ÍÊÇÒ»¸ö¾Û¼¯Ë÷Òý¡£±ÈÈ磬ÎÒÃÇÒª²é“°²”×Ö£¬¾Í»áºÜ×ÔÈ»µØ·¿ª×ÖµäµÄÇ°¼¸Ò³£¬ÒòΪ“°²”µÄÆ´ÒôÊÇ“an”£¬¶ø°´ÕÕÆ´ÒôÅÅÐòºº×ÖµÄ×ÖµäÊÇÒÔÓ¢ÎÄ×Öĸ“a”¿ªÍ·²¢ÒÔ“z”½áβµÄ£¬ÄÇô“°²”×Ö¾Í×ÔÈ»µØÅÅÔÚ×ÖµäµÄÇ°²¿¡£Èç¹ûÄú·ÍêÁËËùÓÐÒÔ“a”¿ªÍ·µÄ²¿·ÖÈÔÈ»ÕÒ²»µ½Õâ¸ö×Ö£¬ÄÇô¾Í˵Ã÷ÄúµÄ×ÖµäÖÐûÓÐÕâ¸ö×Ö£»Í¬ÑùµÄ£¬Èç¹û²é“ÕÅ”×Ö£¬ÄÇÄúÒ²»á½«ÄúµÄ×ֵ䷵½×îºó²¿·Ö£¬ÒòΪ“ÕÅ”µÄÆ´ÒôÊÇ“zhang”¡£Ò²¾ÍÊÇ˵£¬×ÖµäµÄÕýÎIJ¿·Ö±¾Éí¾ÍÊÇÒ»¸öĿ¼£¬Äú²»ÐèÒªÔÙÈ¥²éÆäËûĿ¼À´ÕÒµ½ÄúÐèÒªÕÒµÄÄÚÈÝ¡£
ÎÒÃÇ°ÑÕâÖÖÕýÎÄÄÚÈݱ¾Éí¾ÍÊÇÒ»ÖÖ°´ÕÕÒ»¶¨¹æÔòÅÅÁеÄĿ¼³ÆΪ“¾Û¼¯Ë÷Òý”¡£
Èç¹ûÄúÈÏʶij¸ö×Ö£¬Äú¿ÉÒÔ¿ìËٵشÓ×Ô¶¯Öв鵽Õâ¸ö×Ö¡£µ«ÄúÒ²¿ÉÄÜ»áÓöµ½Äú²»ÈÏʶµÄ×Ö£¬²»ÖªµÀËüµÄ·¢Òô£¬Õâʱºò£¬Äú¾Í²»ÄÜ°´Õողŵķ½·¨ÕÒµ½ÄúÒª²éµÄ×Ö£¬¶øÐèҪȥ¸ù¾Ý“Æ«ÅÔ²¿Ê×”²éµ½ÄúÒªÕÒµÄ×Ö£¬È»ºó¸ù¾ÝÕâ¸ö×ÖºóµÄÒ³ÂëÖ±½Ó·µ½Ä³Ò³À´ÕÒµ½ÄúÒªÕÒµÄ×Ö¡£µ«Äú½áºÏ“²¿Ê×Ŀ¼”ºÍ“¼ì×ֱ픶ø²éµ½µÄ×ÖµÄÅÅÐò²¢²»ÊÇÕæÕýµÄÕýÎĵÄÅÅÐò·½·¨£¬±ÈÈçÄú²é“ÕÅ”×Ö£¬ÎÒÃÇ¿ÉÒÔ¿´µ½Ôڲ鲿Ê×Ö®ºóµÄ¼ì×Ö±íÖГÕÅ”µÄÒ³ÂëÊÇ672Ò³£¬¼ì×Ö±íÖГÕÅ”µÄÉÏÃæÊÇ“³Û”×Ö£¬µ«Ò³ÂëÈ´ÊÇ63Ò³£¬“ÕÅ”µÄÏÂÃæÊÇ “åó”×Ö£¬Ò³ÃæÊÇ390Ò³¡£º
Ïà¹ØÎĵµ£º
use master
go
if exists(select * from dbo.sysobjects where id = object_id(N'[dbo].[P_KillConnections]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[P_KillConnections]
GO
create proc P_KillConnections
@dbname varchar(200)
as
declare @sql nvarchar(500)
declare @spid nvar ......
ÏÂͼÏÔʾÁËÊý¾Ý¿â±¸·ÝʱÎļþ¶ÁдµÄ¹ý³Ì£º
ÔÚ±¸·ÝÆڼ䣬SQL Server»áÔÚÊý¾Ý¿âÎļþÕâ±ßΪÿһÅÌ·û(Volume)´´½¨Ò»¸ö¶ÁÏ̡߳£¶ÁÏ̵߳Ť×÷ºÜ¼òµ¥£¬¾ÍÊÇ´ÓÎļþÖеÄÊý¾ÝÄÚÈÝ¡£Ã¿´ÎÕâ¸öÏ̶߳¼»á´ÓÎļþÖжÁ³ö²¿·ÖÊý¾Ý£¬È»ºó°ÑÊý¾Ý´æµ½»º³åÖÐ(buffer)¡£ÒòΪÓжà¸ö»º³å¿ÉÓã¬ËùÒÔÖ»ÒªÓлº³å¿ÉÒÔдÈëÊý¾Ý£¬¶ÁÏ߳̿ÉÒÔ²»Í£µÄ¶ÁÊý¾Ý¡ ......
¡¡×Ô´ÓSQL Server 2005ÍƳöºó£¬ÒòΪÓÐÁ˸üºÃµÄÐÔÄÜ£¬ËùÒÔÓкܶàÓëSQL Server 2000Ïà¹ØµÄÓ¦ÓóÌÐòÐèÒªÉý¼¶µ½Õâ¸ö°æ±¾¡£µ«ÈçºÎ²ÅÄÜÒÔ×î¿ì×î·½±ãµÄ·½Ê½°ÑÆäÖеıí½á¹¹¼°¶ÔÓ¦µÄÊý¾ÝºÍÊý¾ÝµÄÆäËüµÄ¸ñʽµ¼Èëµ½SQL Server 2005ÄØ£¿SQL Server 2005µÄÊý¾ÝÓÖÈçºÎµ¼Èëµ½SQL Server 2000ÉÏ£¿ÎÒÃÇ·Ö±ðÀ´¿´ÏÂÃæʵÏֵķ½Ê½£º
¡¡¡¡1) SQL ......
¾¹ýÁ˼¸´ÎµÄ²âÊÔÖÕÓڳɹ¦ÁË
declare @Year Int,
@Month int,
@Day int,
@Temp_No varchar(12),
@NeedNo varchar(4),
......
Ê×ÏÈ£¬ÎÒÃÇ¿´¿´existsºÍinµÄЧÂÊÎÊÌ⣬ÕâÀïÎÒֻ˵Ã÷Ò»ÖÖ²âÊÔÓï¾ä
set statistics io on
sqlstatement
set statistics io off¡¢
»òÕß
set statistics time on
sqlstatement
set statistics time off
´ÓstudioÀïÃæµÄÏûÏ¢¿ÉÒÔ¿´³öÎÊÌ⣬ÎÒÒýÓÃÍøÉϵÄһЩ׼Ôòhttp://www.cnblogs.com/diction/arch ......