SQL Server²éѯËٶȻºÂý½â¾ö°ì·¨(1)
SQL ServerÊý¾Ý¿â²éѯËÙ¶ÈÂýµÄÔÒòÓкܶ࣬³£¼ûµÄÓÐÒÔϼ¸ÖÖ£º
1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
4¡¢ÄÚ´æ²»×ã
5¡¢ÍøÂçËÙ¶ÈÂý
6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿)
7¡¢Ëø»òÕßËÀËø(ÕâÒ²ÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
8¡¢sp_lock,sp_who£¬»î¶¯µÄÓû§²é¿´£¬ÔÒòÊǶÁд¾ºÕù×ÊÔ´¡£
9¡¢·µ»ØÁ˲»±ØÒªµÄÐкÍÁÐ
10¡¢²éѯÓï¾ä²»ºÃ£¬Ã»ÓÐÓÅ»¯
¡ñ¿ÉÒÔͨ¹ýÒÔÏ·½·¨À´ÓÅ»¯²éѯ£º
1¡¢°ÑÊý¾Ý¡¢ÈÕÖ¾¡¢Ë÷Òý·Åµ½²»Í¬µÄI/OÉ豸ÉÏ£¬Ôö¼Ó¶ÁÈ¡Ëٶȣ¬ÒÔÇ°¿ÉÒÔ½«TempdbÓ¦·ÅÔÚRAID0ÉÏ£¬SQL2000²»ÔÚÖ§³Ö¡£Êý¾ÝÁ¿(³ß´ç)Ô½´ó£¬Ìá¸ßI/OÔ½ÖØÒª¡£
2¡¢×ÝÏò¡¢ºáÏò·Ö¸î±í£¬¼õÉÙ±íµÄ³ß´ç(sp_spaceuse)
3¡¢Éý¼¶Ó²¼þ
4¡¢¸ù¾Ý²éѯÌõ¼þ£¬½¨Á¢Ë÷Òý£¬ÓÅ»¯Ë÷Òý¡¢ÓÅ»¯·ÃÎÊ·½Ê½£¬ÏÞÖƽá¹û¼¯µÄÊý¾ÝÁ¿¡£×¢ÒâÌî³äÒò×ÓÒªÊʵ±(×îºÃÊÇʹÓÃĬÈÏÖµ0)¡£Ë÷ÒýÓ¦¸Ã¾¡Á¿Ð¡£¬Ê¹ÓÃ×Ö½ÚÊýСµÄÁн¨Ë÷ÒýºÃ(²ÎÕÕË÷ÒýµÄ´´½¨)£¬²»Òª¶ÔÓÐÏ޵ļ¸¸öÖµµÄ×ֶν¨µ¥Ò»Ë÷ÒýÈçÐÔ±ð×ֶΡ£
5¡¢Ìá¸ßÍøËÙ¡£
6¡¢À©´ó·þÎñÆ÷µÄÄÚ´æ,Windows 2000ºÍSQL server 2000ÄÜÖ§³Ö4-8GµÄÄÚ´æ¡£
ÅäÖÃÐéÄâÄڴ棺ÐéÄâÄÚ´æ´óСӦ»ùÓÚ¼ÆËã»úÉϲ¢·¢ÔËÐеķþÎñ½øÐÐÅäÖá£ÔËÐÐMicrosoft SQL Server 2000ʱ£¬¿É¿¼Âǽ«ÐéÄâÄÚ´æ´óСÉèÖÃΪ¼ÆËã»úÖа²×°µÄÎïÀíÄÚ´æµÄ1.5±¶¡£Èç¹ûÁíÍâ°²×°ÁËÈ«ÎļìË÷¹¦ÄÜ£¬²¢´òËãÔËÐÐMicrosoftËÑË÷·þÎñÒÔ±ãÖ´ÐÐÈ«ÎÄË÷ÒýºÍ²éѯ£¬¿É¿¼ÂÇ£º½«ÐéÄâÄÚ´æ´óСÅäÖÃΪÖÁÉÙÊǼÆËã»úÖа²×°µÄÎïÀíÄÚ´æµÄ3±¶¡£½«SQL Server max server memory·þÎñÆ÷ÅäÖÃÑ¡ÏîÅäÖÃΪÎïÀíÄÚ´æµÄ1.5±¶(ÐéÄâÄÚ´æ´óСÉèÖõÄÒ»°ë)¡£
7¡¢Ôö¼Ó·þÎñÆ÷CPU¸öÊý£»µ«ÊDZØÐëÃ÷°×²¢Ðд¦Àí´®Ðд¦Àí¸üÐèÒª×ÊÔ´ÀýÈçÄڴ档ʹÓò¢Ðл¹ÊÇ´®ÐгÌÊÇMSSQL×Ô¶¯ÆÀ¹ÀÑ¡ÔñµÄ¡£µ¥¸öÈÎÎñ·Ö½â³É¶à¸öÈÎÎñ£¬¾Í¿ÉÒÔÔÚ´¦ÀíÆ÷ÉÏÔËÐС£ÀýÈçµ¢¸é²éѯ µÄÅÅÐò¡¢Á¬½Ó¡¢É¨ÃèºÍGROUP BY×Ö¾äͬʱִÐУ¬SQL SERVER¸ù¾ÝϵͳµÄ¸ºÔØÇé¿ö¾ö¶¨×îÓŵIJ¢Ðеȼ¶£¬¸´ÔÓµÄÐèÒªÏûºÄ´óÁ¿µÄCPUµÄ²éѯ×îÊʺϲ¢Ðд¦Àí¡£µ«ÊǸüвÙ×÷UPDATE£¬INSERT£¬DELETE»¹²»Äܲ¢Ðд¦Àí¡£
8¡¢Èç¹ûÊÇʹÓÃlike½øÐвéѯµÄ»°£¬¼òµ¥µÄʹÓÃindexÊDz»Ðеģ¬µ«ÊÇÈ«ÎÄË÷Òý£¬ºÄ¿Õ¼ä¡£like “a%”ʹÓÃË÷Òýlike “%a” ²»Ê¹ÓÃË÷ÒýÓÃlike “%a%” ²éѯʱ£¬²éѯºÄʱºÍ×Ö¶ÎÖµ×ܳ¤¶È³ÉÕý±È£¬ËùÒÔ²»ÄÜÓÃCHARÀàÐÍ£¬¶øÊÇVARCHAR¡£¶ÔÓÚ×ֶεÄÖµºÜ³¤µÄ½¨È«ÎÄË÷Ò
Ïà¹ØÎĵµ£º
1.Êý¾ÝµÄ·Ö²¼Skip()ºÍtake()
Skip(100)´ú±íÌø¹ý100Ðкó.´ÓµÚ101ÐпªÊ¼·ÖÒ³;
take(10)±íʾ¶àÉÙÐзÖÒ³;
Àý:
var result=from pdt in db.Product
select pdt;
this.dataview.DataSource=result.Skip(10).take(10);
......
½¨±í£º
CREATE TABLE [DB.dbo].tableName
(Stud_id int CONSTRAINT constraintName1 not null primary key,
Name nvarchar(5) not null,
Birthday datetime,
Gender nchar(1),
Telcode char(12),
Zipcode char(6) CONSTRAINT constraintName2 CHECK(zipcode like [ ......
¼ò½é
ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÁоÙһЩsqlÓï¾äÀ´½éÉÜÊý¾Ý¿â£¬Êý¾Ý±í£¬ÊÓͼµÈµÈ¡£µ±ÎÒÃÇÔÚʹÓòéѯ²éѯ²Ù×÷ʱÕâЩsqlÓï¾ä¶¼ÊǷdz£ÓÐÓõġ£ËäÈ»ÔÚsql server¶ÔÏóä¯ÀÀÆ÷ÖÐÎÒÃÇÒ²¿ÉÒÔ»ñµÃÕâЩÓï¾ä£¬µ«ÊÇÈç¹ûÎÒÃÇдÕâЩÓï¾äʱÎÒÃÇ¿ÉÒÔ½«Ëü×Ô¶¨Òå¡£Õâ¾ÍÒâζ×ÅÎÒÃÇ¿ÉÒÔ¸øÓè×Ô¼ºµÄÐèÇóÀ´¹ýÂ˽á¹û¡£
sqlÓï¾äÁбí
ÈçºÎÁоÙsql serverµ±Ç°Á ......
==============================================
µÚ1½²
ÔÚÏß¹Û¿´£º http://www.boobooke.com/v/bbk1389
ÊÓƵÏÂÔØ£º http://www.boobooke.com/v/bbk1389.zip
µÚ2½²
ÔÚÏß¹Û¿´£º http://www.boobooke.com/v/bbk1390
ÊÓƵÏÂÔØ£º http://www.boobooke.com/v/bbk1390.zip
µÚ3½²
ÔÚÏß¹Û¿´£º http ......
String keyword = request.getParameter("keyword");
String timeRange = request.getParameter("timeRange");
String type = request.getParameter("type");
StringBuffer sql = new StringBuffer();
sql.append("use webstation_leadall s ......