SQL ServerË÷ÒýÔÔò
ÈçºÎÈÃÄãµÄSQLÔËÐеøü¿ì
---- ÈËÃÇÔÚʹÓÃSQLʱÍùÍù»áÏÝÈëÒ»¸öÎóÇø£¬¼´Ì«¹Ø×¢ÓÚËùµÃµÄ½á¹ûÊÇ·ñÕýÈ·£¬¶øºöÂÔÁ˲»Í¬µÄʵÏÖ·½·¨Ö®¼ä¿ÉÄÜ´æÔÚµÄÐÔÄܲîÒ죬ÕâÖÖÐÔÄܲîÒìÔÚ´óÐ͵ĻòÊǸ´ÔÓµÄÊý¾Ý¿â»·¾³ÖУ¨ÈçÁª»úÊÂÎñ´¦ÀíOLTP»ò¾ö²ßÖ§³ÖϵͳDSS£©ÖбíÏÖµÃÓÈΪÃ÷ÏÔ¡£±ÊÕßÔÚ¹¤×÷ʵ¼ùÖз¢ÏÖ£¬²»Á¼µÄSQLÍùÍùÀ´×ÔÓÚ²»Ç¡µ±µÄË÷ÒýÉè¼Æ¡¢²»³ä·ÝµÄÁ¬½ÓÌõ¼þºÍ²»¿ÉÓÅ»¯µÄwhere×Ӿ䡣ÔÚ¶ÔËüÃǽøÐÐÊʵ±µÄÓÅ»¯ºó£¬ÆäÔËÐÐËÙ¶ÈÓÐÁËÃ÷ÏÔµØÌá¸ß£¡ÏÂÃæÎÒ½«´ÓÕâÈý¸ö·½Ãæ·Ö±ð½øÐÐ×ܽ᣺
---- ΪÁ˸üÖ±¹ÛµØ˵Ã÷ÎÊÌ⣬ËùÓÐʵÀýÖеÄSQLÔËÐÐʱ¼ä¾ù¾¹ý²âÊÔ£¬²»³¬¹ý£±ÃëµÄ¾ù±íʾΪ£¨< 1Ã룩¡£
---- ²âÊÔ»·¾³--
---- Ö÷»ú£ºHP LH II
---- Ö÷Ƶ£º330MHZ
---- Äڴ棺128Õ×
---- ²Ù×÷ϵͳ£ºOperserver5.0.4
---- Êý¾Ý¿â£ºSybase11.0.3
Ò»¡¢²»ºÏÀíµÄË÷ÒýÉè¼Æ
----Àý£º±írecordÓÐ620000ÐУ¬ÊÔ¿´ÔÚ²»Í¬µÄË÷ÒýÏ£¬ÏÂÃ漸¸ö SQLµÄÔËÐÐÇé¿ö£º
---- 1.ÔÚdateÉϽ¨ÓÐÒ»·Ç¸öȺ¼¯Ë÷Òý
select count(*) from record where date >
'19991201' and date < '19991214'and amount >
2000 (25Ãë)
select date,sum(amount) from record group by date
(55Ãë)
select count(*) from record where date >
'19990901' and place in ('BJ','SH') (27Ãë)
---- ·ÖÎö£º
----dateÉÏÓдóÁ¿µÄÖظ´Öµ£¬ÔÚ·ÇȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏËæ»ú´æ·ÅÔÚÊý¾ÝÒ³ÉÏ£¬ÔÚ·¶Î§²éÕÒʱ£¬±ØÐëÖ´ÐÐÒ»´Î±íɨÃè²ÅÄÜÕÒµ½ÕâÒ»·¶Î§ÄÚµÄÈ«²¿ÐС£
---- 2.ÔÚdateÉϵÄÒ»¸öȺ¼¯Ë÷Òý
select count(*) from record where date >
'19991201' and date < '19991214' and amount >
2000 £¨14Ã룩
select date,sum(amount) from record group by date
£¨28Ã룩
select count(*) from record where date >
'19990901' and place in ('BJ','SH')£¨14Ã룩
---- ·ÖÎö£º
---- ÔÚȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏ°´Ë³ÐòÔÚÊý¾ÝÒ³ÉÏ£¬Öظ´ÖµÒ²ÅÅÁÐÔÚÒ»Æð£¬Òò¶øÔÚ·¶Î§²éÕÒʱ£¬¿ÉÒÔÏÈÕÒµ½Õâ¸ö·¶Î§µÄÆðÄ©µã£¬ÇÒÖ»ÔÚÕâ¸ö·¶Î§ÄÚɨÃèÊý¾ÝÒ³£¬±ÜÃâÁË´ó·¶ Î§É¨Ã裬Ìá¸ßÁ˲éѯËٶȡ£
---- 3.ÔÚplace£¬date£¬amountÉϵÄ×éºÏË÷Òý
select count(*) from record where date >
'19991201' and date < '19991214' and amount >
2000 £¨26Ã룩
select date,sum(amount) from record group by date
£¨27Ã룩
select count(*) from record where date >
'19990901' and pl
Ïà¹ØÎĵµ£º
1¡¢²éѯÁ½¸öʱ¼äÖ®¼ä
select * from [tablename] where date between \'value1\' and \'value2\'
2¡¢ÏÔʾ×îºó»Ø¸´Ê±¼ä
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
3¡¢Èճ̰²ÅÅÌáÇ°5·ÖÖÓÌáÐÑ
select * from Èճ̰²ÅÅ w ......
Ò»¡¢ PL/SQLÓïÑÔ¼ò½é
(±¾½²ÒåÖ®ËùÓгÌÐò¾ùµ÷ʽͨ¹ý)
Ê×ÏÈÎÒÃÇ¿´Ò»¸ö¼òµ¥Ö®Àý×Ó,ÏÂÃæÕâ¸öÀý×ÓÊÇͳ¼Æ´Ó1ÖÁ100µÄ×ܺÍ.
declare
i number:=0; /*ÉùÃ÷±äÁ¿¾®¸ø³õÖµ*/
t number:=1;
error_message exception; /*ÉùÃ÷Ò»¸ö³ö´í´¦Àí*/
begin
......
Õë¶Ô SQL Server ÄÚÕýÔÚÖ´ÐеÄÿ¸öÇëÇó·µ»ØÒ»ÐС£sys.dm_exec_connections
¡¢sys.dm_exec_sessions
ºÍsys.dm_exec_requests
·þÎñÆ÷·¶Î§¶¯Ì¬¹ÜÀíÊÓͼӳÉäµ½ sys.sysprocesses
ϵͳÊÓͼ£¨ÏÈǰΪϵͳ±í£©¡£
×¢Ò⣺
ÈôÒªÖ´ÐÐÔÚ SQL Server ÒÔÍâµÄ´úÂ루ÀýÈ磬À©Õ¹´æ´¢¹ý³ÌºÍ·Ö ......
SQL 2005 µÄ´æ´¢¹ý³ÌºÍ´¥·¢Æ÷µ÷ÊԴ󷨣¨Ô´´£©
www.chengchen.net ³Ì³¿
×òÌìÍíÉÏÎÒÕÒ±éÁË»¥ÁªÍøҲûÓз¢ÏÖ¹ØÓÚSQL2005´æ´¢¹ý³ÌºÍ´¥·¢Æ÷µÄµ÷ÊÔ·½·¨£¬Ñо¿µ½Á賿2µã¶àÖÓ£¬ÖÕÓÚÕÒµ½·½·¨ÁË£¬²»¸É¶ÀÏí£¬ÄóöÀ´·ÖÏí¡£Èç¹ûҪתÔØ£¬Çë±£Áô°æȨ£¬Ð»Ð»£¡
&nbs ......
¸øÄã¸ö×îÏêϸµÄ°É ¿ÉÄÜÓÐÄãÒªµÄÄÚÈÝ
ËøµÄ¸ÅÊö
Ò». ΪʲôҪÒýÈëËø
¶à¸öÓû§Í¬Ê±¶ÔÊý¾Ý¿âµÄ²¢·¢²Ù×÷ʱ»á´øÀ´ÒÔÏÂÊý¾Ý²»Ò»ÖµÄÎÊÌâ:
¶ªÊ§¸üÐÂ
A,BÁ½¸öÓû§¶ÁͬһÊý¾Ý²¢½øÐÐÐÞ¸Ä,ÆäÖÐÒ»¸öÓû§µÄÐ޸Ľá¹ûÆÆ»µÁËÁíÒ»¸öÐ޸ĵĽá¹û,±ÈÈ綩Ʊϵͳ
Ôà¶Á
AÓû§ÐÞ¸ÄÁËÊý¾Ý,ËæºóBÓû§ÓÖ¶Á³ö¸ÃÊý¾Ý,µ«AÓû§ÒòΪijЩÔÒòÈ¡Ï ......