sql server 2000 È«ÎÄË÷ÒýÈ«½â
http://hi.baidu.com/dumao/blog/item/1cafa71e5886d019413417e4.html
1.È«ÎÄË÷Òý¸ÅÊö
¶Ô Microsoft® SQL Server™ 2000 Êý¾ÝµÄÈ«ÎÄÖ§³ÖÉæ¼°Á½¸ö¹¦ÄÜ£º¶Ô×Ö·ûÊý¾Ý·¢³ö²éѯµÄÄÜÁ¦ºÍ´´½¨¼°Î¬»¤»ù´¡Ë÷ÒýÒÔ¼ò»¯ÕâЩ²éѯµÄÄÜÁ¦¡£
È«ÎÄË÷ÒýÔÚÐí¶àµØ·½ÓëÆÕͨµÄ SQL Ë÷Òý²»Í¬¡£
ÆÕͨ SQL Ë÷ÒýÈ«ÎÄË÷Òý
´æ´¢Ê±Êܶ¨ÒåËüÃÇËùÔÚµÄÊý¾Ý¿âµÄ¿ØÖÆ¡£
´æ´¢ÔÚÎļþϵͳÖУ¬µ«Í¨¹ýÊý¾Ý¿â¹ÜÀí¡£
ÿ¸ö±íÔÊÐíÓÐÈô¸É¸öÆÕͨË÷Òý¡£
ÿ¸ö±íÖ»ÔÊÐíÓÐÒ»¸öÈ«ÎÄË÷Òý¡£
µ±¶Ô×÷ΪÆä»ù´¡µÄÊý¾Ý½øÐвåÈë¡¢¸üлòɾ³ýʱ£¬ËüÃÇ×Ô¶¯¸üС£
½«Êý¾ÝÌí¼Óµ½È«ÎÄË÷Òý³ÆΪÌî³ä£¬È«ÎÄË÷Òý¿Éͨ¹ýµ÷¶È»òÌض¨ÇëÇóÀ´ÇëÇó£¬Ò²¿ÉÒÔÔÚÌí¼ÓÐÂÊý¾Ýʱ×Ô¶¯·¢Éú¡£
²»·Ö×é¡£
ÔÚͬһ¸öÊý¾Ý¿âÄÚ·Ö×éΪһ¸ö»ò¶à¸öÈ«ÎÄĿ¼¡£
ʹÓà SQL Server ÆóÒµ¹ÜÀíÆ÷¡¢Ïòµ¼»ò Transact-SQL Óï¾ä´´½¨ºÍ³ýÈ¥¡£
ʹÓà SQL Server ÆóÒµ¹ÜÀíÆ÷¡¢Ïòµ¼»ò´æ´¢¹ý³Ì´´½¨¡¢¹ÜÀíºÍ³ýÈ¥¡£
ÕâЩ²îÒìʹ´óÁ¿¹ÜÀíÈÎÎñ±äµÃ²»¿ÉȱÉÙ¡£È«ÎĹÜÀíÊÇÔÚ¼¸¸ö²ã´ÎÉÏʵʩµÄ£º
·þÎñÆ÷
¿ÉÒÔ¶Ô·þÎñÆ÷·¶Î§µÄijЩÊôÐÔ£¨Èç resource_usage£©¼ÓÒÔÉèÖã¬ÒÔ±ãÔö¼Ó»ò¼õÉÙÈ«ÎÄ·þÎñËùʹÓõÄϵͳ×ÊÔ´ÊýÁ¿¡£
˵Ã÷ È«ÎÄÒýÇæ×÷ΪÃûΪ Microsoft ËÑË÷µÄ·þÎñÔÚ Microsoft Windows NT® Server ºÍ Microsoft Windows® 2000 Server ÉÏÔËÐС£¶ÔÓÚ Microsoft SQL Server ¸öÈ˰棬Microsoft ËÑË÷·þÎñ²»¿ÉÓ᣾¡¹ÜÕâÒâζ×Å Microsoft ËÑË÷·þÎñ¼Èδ°²×°ÔÚ Microsoft Windows 95/98 ÉÏ£¬Ò²Î´°²×°ÔÚ Windows NT ¹¤×÷Õ¾»ò Windows 2000 Professional ¿Í»§¶ËÉÏ£¬µ«ÕâЩ¿Í»§¶ËÔÚÁ¬½Óµ½ SQL Server ±ê×¼°æ°²×°»òÆóÒµ°æʵÀýʱ¿ÉÒÔʹÓÃÕâÏî·þÎñ¡£
Êý¾Ý¿â
±ØÐëÆôÓÃÊý¾Ý¿â²ÅÄÜʹÓÃÈ«ÎÄ·þÎñ¡£¿ÉÒÔÔÚÒÑÆôÓõÄÊý¾Ý¿âÖд´½¨ºÍ³ýÈ¥Ò»¸ö»ò¶à¸öÈ«ÎÄĿ¼µÄÔªÊý¾Ý¡£
È«ÎÄĿ¼
È«ÎÄĿ¼°üº¬Êý¾Ý¿âÖеÄÈ«ÎÄË÷Òý¡£Ã¿¸öĿ¼¿ÉÒÔÓÃÓÚÊý¾Ý¿âÄÚµÄÒ»¸ö»ò¶à¸ö±íµÄË÷ÒýÐèÇ󡣸ÃĿ¼ÖеÄË÷ÒýÊÇʹÓÃÕâÀï½éÉܵĹÜÀí¹¦ÄÜÀ´Ìî³äµÄ¡££¨È«ÎÄĿ¼±ØÐëפÁôÔÚÓë SQL Server ʵÀýÏà¹ØÁªµÄ±¾µØÓ²ÅÌÇý¶¯Æ÷ÉÏ¡£²»Ö§³Ö¿ÉÒƶ¯µÄÇý¶¯Æ÷¡¢ÈíÅ̺ÍÍøÂçÇý¶¯Æ÷£©¡£ÔÚÿ¸ö·þÎñÆ÷ÉÏ×î¶à¿É´´½¨ 256 ¸öÈ«ÎÄĿ¼¡£
˵Ã÷ Windows NT ¹ÊÕÏתÒÆȺ¼¯»·¾³ÍêÈ«Ö§³ÖÈ«ÎÄË÷Òý¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼ûÔÚ¹ÊÕÏתÒÆȺ¼¯ÖÐÔËÐÐÈ«ÎIJéѯ¡£
±í
Ê×ÏÈ£¬±ØÐëΪȫÎÄÖ§³ÖÆôÓÃ±í¡£È»ºó£¬ÎªÓë¸Ã±íÏà¹ØÁªµÄÈ«ÎÄË÷Òý´´½¨ÔªÊý¾Ý£¨Èç±íÃû¼°ÆäÈ«ÎÄĿ¼£©¡£±íÆôÓú󣬿ÉÒÔÓÃΪȫÎÄÖ§³Ö¶
Ïà¹ØÎĵµ£º
ÔÚSQL ServerÀï²é¿´µ±Ç°Á¬½ÓµÄÔÚÏßÓû§Êý
use master
select loginame,count(0) from sysprocesses
group by loginame
order by count(0) desc
select nt_username,count(0) from sysprocesses
group by nt_username
order by count(0) desc
Èç¹ûij¸öSQL ServerÓû§ÃûtestÁ¬½Ó±È½Ï¶à,²é¿´ËüÀ´×ÔµÄÖ÷»úÃû:
......
×î½üÒ»Ö±ÔÚѧϰSQL serverµÄÄÚÈÝ¡£×òÌ쿼ÁËÒ»ÏÂÊÔ¡£¸Ð¾õÕæµÄÊDz»ÈÝÒ×°¡¡£ÌرðÊÇһЩ¸´ÔӵIJéѯ¡£¸ãµÃÎÒÍ·»èÄÔÕ͵ġ£²»¹ýÒ²ÊÇÓÉÓÚ×Ô¼ºµÄ֪ʶÕÆÎյĻ¹²»¹»Ôúʵ°¡¡£ËùÒÔ½ñÌ츴ϰÁËÒ»ÏÂT-SQlÓï¾äµÄÔöɾ¸Ä²é¡£·¢ÏÖµÄÈ·ÊÇÓкܶ඼Íü¼ÇÁË¡£ÏÖÔڰѽá¹ûд³öÀ´¡£ÒÔºó¿É²»ÒªÍüÁËѽ¡£
--SQLÓï¾ä¸´Ï° --Ò»,²åÈëinsertÓï¾ä --1,ins ......
1 windowsµÇ¼ÕË»§¿Ú£ºEXEC ap_grantlogin 'windowsÓòÃû\ÓòÕË»§'
2 SQL µÇ¼ÕË»§:EXEC sp_addlogin 'ÕË»§Ãû','ÃÜÂë'
3 ´´½¨Êý¾Ý¿âÓû§:exec spgrantdbaccess 'µÇ¼ÕË»§','Êý¾Ý¿âÓû§'
¶þ ¸øÊý¾Ý¿âÓû§ÊÚȨ
grant ȨÏÞ on ±íÃû to Êý¾Ý¿âÓû§ ......
sql×¢È룬ËùνSQL×¢È룬¾ÍÊÇͨ¹ý°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÝ½»»òÊäÈëÓòÃû»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬×îÖÕ´ïµ½ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁ±ÈÈçÏÈÇ°µÄºÜ¶àÓ°ÊÓÍøվй¶VIP»áÔ±ÃÜÂë´ó¶à¾ÍÊÇͨ¹ýWEB±íµ¥µÝ½»²éѯ×Ö·û±©³öµÄ£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷£®
¡¡¡¡µ±Ó¦ÓóÌÐòʹÓÃÊäÈëÄÚÈÝÀ´¹¹Ô춯 ......
sqlÓï¾ä£¬È¡³ö±íAÖеĵÚ31Ìõµ½40Ìõ¼Ç¼£¨±íAÒÔ×Ô¶¯Ôö³¤µÄID×öÖ÷¼ü£¬×¢ÒâID¿ÉÄÜÊDz»Á¬ÐøµÄ£©
-->select top 10 * from a where id not in (select top 30 id from a order by id) order by id
²éѯǰʮÌõ¼Ç¼£¬µ«Ìõ¼þÊÇ£ºID²»ÔÚÇ°ÈýÊ®ÌõµÄIDÀïÃæ
-->select top 10 * from (select top 40 ......