sql 2005 rownumÓ÷¨ÒÔ¼°´øorder by ×Ó²éѯµÄÓ÷¨
-- sql 2005
1.rownumÓ÷¨
select * from(
Select rownum=row_number() over(order by 1),* from table
)a where rownum between 1 and 10
2.´øorder by ×Ó²éѯµÄÓ÷¨
sleect * from(select TOP 100 percent * from table order id ) a
Ïà¹ØÎĵµ£º
SQL 2005 µÄ´æ´¢¹ý³ÌºÍ´¥·¢Æ÷µ÷ÊԴ󷨣¨Ô´´£©
www.chengchen.net ³Ì³¿
×òÌìÍíÉÏÎÒÕÒ±éÁË»¥ÁªÍøҲûÓз¢ÏÖ¹ØÓÚSQL2005´æ´¢¹ý³ÌºÍ´¥·¢Æ÷µÄµ÷ÊÔ·½·¨£¬Ñо¿µ½Á賿2µã¶àÖÓ£¬ÖÕÓÚÕÒµ½·½·¨ÁË£¬²»¸É¶ÀÏí£¬ÄóöÀ´·ÖÏí¡£Èç¹ûҪתÔØ£¬Çë±£Áô°æȨ£¬Ð»Ð»£¡
&nbs ......
TEMPDB²»Ö§³Ö×Ô¶¯Ñ¹Ëõ£¬ÇÒËüµÄÊý¾Ý¿âºÍÎļþѹËõÄÜÁ¦ÊÇÓÐÏÞÖƵģ»
Èç²»µÃ²»Ñ¹ËõTEMPDBµÄ´óС£¬½¨ÒéʹÓÃÀëÏß¹¦ÄÜ£¬ÈçϲÙ×÷£º
1.Í£Ö¹SQL SERVER·þÎñ£»
2.ÕÒµ½sqlservr.exeÔÚ´ÅÅÌÖеÄλÖã»
3.ʹÓÃsqlservr.exeÊäÈëÃüÁîsqlservr -c -f,ÕâÑùÆô¶¯SQL SERVERʱ£¬TEMPDBµÄ´óСÄܹ»±£³Ö×îС£»
4.ʹÓÃTSQLÃüÁALTER DATA ......
¸øÄã¸ö×îÏêϸµÄ°É ¿ÉÄÜÓÐÄãÒªµÄÄÚÈÝ
ËøµÄ¸ÅÊö
Ò». ΪʲôҪÒýÈëËø
¶à¸öÓû§Í¬Ê±¶ÔÊý¾Ý¿âµÄ²¢·¢²Ù×÷ʱ»á´øÀ´ÒÔÏÂÊý¾Ý²»Ò»ÖµÄÎÊÌâ:
¶ªÊ§¸üÐÂ
A,BÁ½¸öÓû§¶ÁͬһÊý¾Ý²¢½øÐÐÐÞ¸Ä,ÆäÖÐÒ»¸öÓû§µÄÐ޸Ľá¹ûÆÆ»µÁËÁíÒ»¸öÐ޸ĵĽá¹û,±ÈÈ綩Ʊϵͳ
Ôà¶Á
AÓû§ÐÞ¸ÄÁËÊý¾Ý,ËæºóBÓû§ÓÖ¶Á³ö¸ÃÊý¾Ý,µ«AÓû§ÒòΪijЩÔÒòÈ¡Ï ......
ÏÈÕ¾ÔÚÓ¦ÓóÌÐòµÄ½Ç¶È˵˵ËüÃǵIJ»Í¬¡£
1¡¢ Ö±½ÓÆ´ SQL
¾ÍÏñ´ó¼ÒÁ˽âµÄÄÇÑù£¬Ö±½ÓÆ´ SQL ´øÀ´ÁË SQL ×¢Èë¹¥»÷£¬´øÀ´ÁËƴʱЩÐíµÄÐÔÄÜËðʧ£¬µ«ÊÇÆ´²»ÓÃÌí¼Ó SqlParameter £¬»áÉÙдºÜ¶à´úÂë——ºÜ¶àÈËϲ»¶Ö±½ÓÆ´£¬Ò²Ðí¾ÍÒòΪÕâµã¡£ÕâÖÖ×ö·¨»á°ÑÄãÆ´ºÃµÄ SQL ÔÑùÖ±½Ó·¢Ë͵½ DB ·þÎñÆ÷È¥Ö´ÐС££¨×¢ÒâÀàËÆ &rdquo ......
ÉÏ»ØÎÒÃÇ˵µ½ÆÀ¹ÀÒ»ÌõÓï¾äÖ´ÐÐЧÂÊÖ÷Òª¿´Âß¼ IO £¨É¶ÊÇÂß¼ IO £¬É¶ÊÇÎïÀí IO ¼ûÁª»úÎĵµ£©£¬Õâ´ÎÎÒÃǼÌÐø¡£
ÎÒÃÇÏÈ˵˵£¬·µ»Ø¶àÐнá¹ûʱ£¬ÎªÊ²Ã´ SQLServer ÓÐʱ»áÑ¡Ôñ index seek £¬ÓÐʱ»áÑ¡Ôñ index scan ¡£
ÒÔ nonclustered index ΪÀý˵Ã÷¡£
ÏñËùÓеÄË÷Òý B Ê÷Ò»Ñù£¬·Ç¾Û¼¯Ë÷ÒýÊ÷Ò²°üÀ¨ÍêÈ«ÓÉË÷ÒýÊý¾Ý×é³ÉµÄ¸ù½ ......