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

SQL Server ²éѯÓÅ»¯£¨3£©_Ë÷ÒýµÄÉè¼ÆÓëʹÓÃ

Ò»¡¢Ë÷ÒýµÄ×÷ÓÃ
1¡¢°ïÖú¼ìË÷Êý¾Ý£»
2¡¢Ìá¸ßÁª½ÓЧÂÊ£»
3¡¢½ÚÊ¡ORDER BY¡¢GROUP BYµÄʱ¼ä£»
4¡¢±£Ö¤Êý¾ÝΨһÐÔ£¨½öÏÞÓÚΨһË÷Òý£©¡£
 
¶þ¡¢Ë÷ÒýµÄÉè¼Æ
ÔÚÈ·¶¨Òª½¨Á¢Ò»¸öË÷Òýʱ£¬Ê×ÏÈÎÒÃÇҪȷ¶¨ËüÊǾۼ¯»¹ÊǷǾۼ¯¡¢µ¥Áл¹ÊǶàÁС¢Î¨Ò»»¹ÊÇ·ÇΨһ¡¢ÁÐÊÇÉýÐò»¹ÊǽµÐò¡¢ËüµÄ´æ´¢ÊÇÈçºÎµÄ£¬±ÈÈ磺·ÖÇø¡¢Ìî³äÒò×ӵȡ£ÏÂÃæÖðÌõÀ´¿´£º
1¡¢¾Û¼¯Ë÷Òý
£¨1£©Ê×ÏÈÖ¸³öÒ»¸öÎóÇø£¬Ö÷¼ü²¢²»Ò»¶¨ÊǾۼ¯Ë÷Òý£¬Ö»ÊÇÔÚSQL SERVERÖУ¬Î´Ã÷È·Ö¸³öµÄÇé¿öÏ£¬Ä¬ÈϽ«Ö÷¼ü¶¨ÒåΪ¾Û¼¯£¬¶øORACLEÖÐÔòĬÈÏÊǷǾۼ¯£¬ÒòΪSQL SERVERÖеÄROWID먦·ÅʹÓá£
£¨2£©¾Û¼¯Ë÷ÒýÊʺÏÓÃÓÚÐèÒª½øÐз¶Î§²éÕÒµÄÁУ¬ÒòΪ¾Û¼¯Ë÷ÒýµÄÒ¶×Ó½Úµã´æ·ÅµÄÊÇÓÐÐòµÄÊý¾ÝÐУ¬²éѯÒýÇæ¿É¸ù¾ÝWHEREÖиø³öµÄ·¶Î§£¬Ö±½Ó¶¨Î»µ½Á½¶ËµÄÒ¶×ӽڵ㣬½«Õⲿ·Ö½ÚµãÒ³µÄÊý¾Ý¸ù¾ÝÁ´±í˳ÐòÈ¡³ö¼´¿É£»
£¨3£©¾Û¼¯Ë÷Òý¾¡Á¿½¨Á¢ÔÚÖµ²»»á·¢Éú±ä¸üµÄÁÐÉÏ£¬·ñÔò»á´øÀ´·Ç¾Û¼¯Ë÷ÒýµÄά»¤£»
£¨4£©¾¡Á¿ÔÚ½¨Á¢·Ç¾Û¼¯Ë÷Òý֮ǰ½¨Á¢¾Û¼¯Ë÷Òý£¬·ñÔò»áµ¼Ö±íÉÏËùÓзǾۼ¯Ë÷ÒýµÄÖؽ¨£»
£¨5£©¾Û¼¯Ë÷ÒýÓ¦¸Ã±ÜÃ⽨Á¢ÔÚÊýÖµµ¥µ÷µÄÁÐÉÏ£¬·ñÔò¿ÉÄÜ»áÔì³ÉIOµÄ¾ºÕù£¬ÒÔ¼°BÊ÷µÄ²»Æ½ºâ£¬´Ó¶øµ¼ÖÂÊý¾Ý¿âϵͳƵ·±µÄά»¤BÊ÷µÄƽºâÐÔ¡£¾Û¼¯Ë÷ÒýµÄÁÐÖµ×îºÃÄܹ»ÔÚ±íÖоùÔÈ·Ö²¼¡£
 
2¡¢·Ç¾Û½¹Ë÷Òý
£¨1£©·Ç¾Û¼¯Ë÷ÒýÊʺÏÓÃÓÚÐèÒª½øÐеÈÖµ²éÕÒµÄÁУ¬ÒòΪ·Ç¾Û¼¯Ë÷ÒýµÄÒ¶×Ó½Úµã´æ·ÅµÄÊÇÓÐÐòµÄË÷ÒýÁÐÓëÊéÇ©µÄÓ³ÉäÐУ¬²éѯÒýÇæ¿É¸ù¾ÝWHEREÖиø³öµÄÖµ£¬µÃµ½ÊéÇ©£¬¼Ì¶ø¶¨Î»µ½Êý¾ÝÐУ»
£¨2£©¸²¸ÇË÷Òý£¨Covering Index£©£¬ÊǷǾۼ¯Ë÷ÒýµÄÒ»ÖÖÌØÊâÇÒ¸ßЧµÄÓ¦Ó㬾ÍÊǽ«ÐèÒª·µ»ØµÄÊý¾ÝÁÐÉè¼Æ³É×éºÏË÷Òý£¬ÔÚSELECTʱֻ²éѯË÷ÒýÖдæÔÚµÄÊý¾ÝÁУ¬ÕâÑù¾ÍÄÜÐγÉË÷Òý¸²¸Ç£¬ÒòΪË÷ÒýÐÐÖÐÒѾ­°üº¬ÁËÏëµ½µÄÊý¾Ý£¬²»ÐèÒªÔÙ½øÐÐÊéÇ©²éÕÒ£»
ÔÚSQL SERVER 2005¼°ÒÔÉÏ°æ±¾ÖУ¬ÌṩÁËINCLUDED¹Ø¼ü×Ö£¬¿ÉÒÔÔڷǾۼ¯Ë÷ÒýÖаüº¬¸ü¶àÁУ¬Ò²ÊǸ²¸ÇË÷ÒýµÄÒ»¸öÓÐЧÒýÉꣻ
£¨3£©·Ç¾Û¼¯Ë÷Òý½¨Á¢ÔÚÖµ¾ßÓе¥µ÷ÐÔµÄÁÐÉÏ£¬±ÈÈ磺×ÔÔöÁУ¨µ¥µ÷µÝÔö£©£¬¿ÉÒÔ¼õÉÙË÷ÒýµÄÍⲿËéƬ¼°Ë÷Òý½á¹¹µÄά»¤£»
 
3¡¢¸´ºÏË÷Òý
£¨1£©¸´ºÏË÷Òý½¨Á¢ÔÚ¶à¸öÁÐÉÏ¡£ÉÏÃæÒѾ­½²¹ý£¬ÔڷǾۼ¯Ë÷ÒýÖУ¬¿ÉÒÔÀûÓø²¸ÇË÷ÒýÀ´Ìá¸ß¼ìË÷µÄЧÂÊ£¬µ«Èç¹û×éºÏË÷ÒýµÄÁÐÌ«¶àµÄ»°£¬ÄÇô¶ÔÓÚÕâ¸öË÷ÒýµÄά»¤³É±¾Ò²»á¼Ó´ó£¬DMLµÄЧÂʽ«»áϽµ£¬¶øÇÒË÷ÒýµÄ²éÕÒ·¾¶»á±ä³¤£»
£¨2£©ÔÚ´´½¨¸´ºÏË÷Òýʱ£¬Ó¦¸Ã½«¸ßÑ¡ÔñÐÔµÄÁзÅÔÚÇ°Ã棬¼´×÷ΪÒýµ¼ÁУ»
 
4¡¢Î¨Ò»Ë÷Òý
£¨1£©ÔÙÖ¸³öÒ»¸öÎóÇø£¬¾Û¼¯Ë÷Òý²¢²»Ò»¶¨ÊÇÎ


Ïà¹ØÎĵµ£º

ASP.NET·ÀSQL×¢Èë½Å±¾³ÌÐò v2.0

public class SqlCheck
{
public SqlCheck()
{
//
// TODO: ÔÚ´Ë´¦Ìí¼Ó¹¹Ô캯ÊýÂß¼­
//
}

public SqlConnection oconn()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["StudyConnectionString"] ......

U9 SQLÓû§×Ô¶¨Ò庯Êý

ÔÚ×ö±¨±íʱoqlÓï¾äÖÐÓÐʱÐèÒªÓõ½Óû§×Ô¶¨Ò庯Êý£¬µ÷ÓÃÖ®ºó±¨±í±¨´í£º¡° ¶ÔÊý¾Ý¼¯¡°DataQuery¡±Ö´Ðвéѯʧ°Ü¡£ 'fn_GetLevelItemCatName' ²»ÊÇ¿ÉÒÔʶ±ðµÄ º¯ÊýÃû³Æ¡£ ')' ¸½½üÓÐÓï·¨´íÎó¡£ ¡° £¬ÓÚÊÇÎÒ½«oqlÓï¾ä½âÎöºóÄÃsqlÓï¾äµ½sql server 2008ÖÐÈ¥Ö´Ðб¨´í£º 'fn_GetLevelItemCatName' ²»ÊÇ¿ÉÒÔʶ±ðµÄº¯ÊýÃû³Æ¡£ ÕâÖÖÎÊÌ ......

sql server 2005 Êý¾ÝÀàÐÍ

SQL Server 2005 ÖеÄÊý¾ÝÀàÐ͹éÄÉΪÏÂÁÐÀà±ð£º
¾«È·Êý×Ö
Unicode ×Ö·û´®
½üËÆÊý×Ö
¶þ½øÖÆ×Ö·û´®
ÈÕÆÚºÍʱ¼ä
ÆäËûÊý¾ÝÀàÐÍ
×Ö·û´®
ÔÚ SQL Server 2005 ÖУ¬¸ù¾ÝÆä´æ´¢ÌØÕ÷£¬Ä³Ð©Êý¾ÝÀàÐͱ»Ö¸¶¨ÎªÊôÓÚÏÂÁи÷×飺
´óÖµÊý¾ÝÀàÐÍ£ºvarchar(max)¡¢nvarchar(max) ºÍ varbinary(max)
´óÐͶÔÏóÊý¾ÝÀàÐÍ£ºtext¡¢ntext¡¢ima ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ