SQL Server Ë÷Òý½á¹¹¼°ÆäʹÓã¨ËÄ£©
¾Û¼¯Ë÷ÒýµÄÖØÒªÐÔºÍÈçºÎÑ¡Ôñ¾Û¼¯Ë÷Òý
¡¡¡¡ÔÚÉÏÒ»½ÚµÄ±êÌâÖУ¬±ÊÕßдµÄÊÇ£ºÊµÏÖСÊý¾ÝÁ¿ºÍº£Á¿Êý¾ÝµÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì¡£ÕâÊÇÒòΪÔÚ½«±¾´æ´¢¹ý³ÌÓ¦ÓÃÓÚ“°ì¹«×Ô¶¯»¯”ϵͳµÄʵ¼ùÖÐʱ£¬±ÊÕß·¢ÏÖÕâµÚÈýÖÖ´æ´¢¹ý³ÌÔÚСÊý¾ÝÁ¿µÄÇé¿öÏ£¬ÓÐÈçÏÂÏÖÏó£º
1¡¢·ÖÒ³ËÙ¶ÈÒ»°ãά³ÖÔÚ1ÃëºÍ3ÃëÖ®¼ä¡£
2¡¢ÔÚ²éѯ×îºóһҳʱ£¬ËÙ¶ÈÒ»°ãΪ5ÃëÖÁ8Ã룬ÄÄÅ·ÖÒ³×ÜÊýÖ»ÓÐ3Ò³»ò30ÍòÒ³¡£
¡¡¡¡ËäÈ»ÔÚ³¬´óÈÝÁ¿Çé¿öÏ£¬Õâ¸ö·ÖÒ³µÄʵÏÖ¹ý³ÌÊǺܿìµÄ£¬µ«ÔÚ·ÖÇ°¼¸Ò³Ê±£¬Õâ¸ö1£3ÃëµÄËٶȱÈÆðµÚÒ»ÖÖÉõÖÁûÓо¹ýÓÅ»¯µÄ·ÖÒ³·½·¨ËٶȻ¹ÒªÂý£¬½èÓû§µÄ»°Ëµ¾ÍÊÇ“»¹Ã»ÓÐAccessÊý¾Ý¿âËٶȿ씣¬Õâ¸öÈÏʶ×ãÒÔµ¼ÖÂÓû§·ÅÆúʹÓÃÄú¿ª·¢µÄϵͳ¡£
¡¡¡¡±ÊÕ߾ʹ˷ÖÎöÁËһϣ¬ÔÀ´²úÉúÕâÖÖÏÖÏóµÄÖ¢½áÊÇÈç´ËµÄ¼òµ¥£¬µ«ÓÖÈç´ËµÄÖØÒª£ºÅÅÐòµÄ×ֶβ»ÊǾۼ¯Ë÷Òý£¡
¡¡¡¡±¾ÆªÎÄÕµÄÌâÄ¿ÊÇ£º“²éѯÓÅ»¯¼°·ÖÒ³Ëã·¨·½°¸”¡£±ÊÕßÖ»ËùÒÔ°Ñ“²éѯÓÅ»¯”ºÍ“·ÖÒ³Ëã·¨”ÕâÁ½¸öÁªÏµ²»ÊǺܴóµÄÂÛÌâ·ÅÔÚÒ»Æ𣬾ÍÊÇÒòΪ¶þÕ߶¼ÐèÒªÒ»¸ö·Ç³£ÖØÒªµÄ¶«Î÷¨D¨D¾Û¼¯Ë÷Òý¡£
ÔÚÇ°ÃæµÄÌÖÂÛÖÐÎÒÃÇÒѾÌáµ½ÁË£¬¾Û¼¯Ë÷ÒýÓÐÁ½¸ö×î´óµÄÓÅÊÆ£º
1¡¢ÒÔ×î¿ìµÄËÙ¶ÈËõС²éѯ·¶Î§¡£
2¡¢ÒÔ×î¿ìµÄËٶȽøÐÐ×Ö¶ÎÅÅÐò¡£
¡¡¡¡µÚ1Ìõ¶àÓÃÔÚ²éѯÓÅ»¯Ê±£¬¶øµÚ2Ìõ¶àÓÃÔÚ½øÐзÖҳʱµÄÊý¾ÝÅÅÐò¡£
¡¡¡¡¶ø¾Û¼¯Ë÷ÒýÔÚÿ¸ö±íÄÚÓÖÖ»Äܽ¨Á¢Ò»¸ö£¬ÕâʹµÃ¾Û¼¯Ë÷ÒýÏԵøü¼ÓµÄÖØÒª¡£¾Û¼¯Ë÷ÒýµÄÌôÑ¡¿ÉÒÔ˵ÊÇʵÏÖ“²éѯÓÅ»¯”ºÍ“¸ßЧ·ÖÒ³”µÄ×î¹Ø¼üÒòËØ¡£
¡¡¡¡µ«Òª¼Èʹ¾Û¼¯Ë÷ÒýÁмȷûºÏ²éѯÁеÄÐèÒª£¬ÓÖ·ûºÏÅÅÐòÁеÄÐèÒª£¬Õâͨ³£ÊÇÒ»¸öì¶Ü¡£±ÊÕßÇ°Ãæ“Ë÷Òý”µÄÌÖÂÛÖУ¬½«fariqi£¬¼´Óû§·¢ÎÄÈÕÆÚ×÷ΪÁ˾ۼ¯Ë÷ÒýµÄÆðʼÁУ¬ÈÕÆڵľ«È·¶ÈΪ“ÈÕ”¡£ÕâÖÖ×÷·¨µÄÓŵ㣬ǰÃæÒѾÌáµ½ÁË£¬ÔÚ½øÐл®Ê±¼ä¶ÎµÄ¿ìËÙ²éѯÖУ¬±ÈÓÃIDÖ÷¼üÁÐÓкܴóµÄÓÅÊÆ¡£
¡¡¡¡µ«ÔÚ·Öҳʱ£¬ÓÉÓÚÕâ¸ö¾Û¼¯Ë÷ÒýÁдæÔÚ×ÅÖظ´¼Ç¼£¬ËùÒÔÎÞ·¨Ê¹ÓÃmax»òminÀ´×îΪ·ÖÒ³µÄ²ÎÕÕÎ½ø¶øÎÞ·¨ÊµÏÖ¸üΪ¸ßЧµÄÅÅÐò¡£¶øÈç¹û½«IDÖ÷¼üÁÐ×÷Ϊ¾Û¼¯Ë÷Òý£¬ÄÇô¾Û¼¯Ë÷Òý³ýÁËÓÃÒÔÅÅÐòÖ®Í⣬ûÓÐÈκÎÓô¦£¬Êµ¼ÊÉÏÊÇÀË·ÑÁ˾ۼ¯Ë÷ÒýÕâ¸ö±¦¹óµÄ×ÊÔ´¡£
¡¡¡¡Îª½â¾öÕâ¸öì¶Ü£¬±ÊÕߺóÀ´ÓÖÌí¼ÓÁËÒ»¸öÈÕÆÚÁУ¬ÆäĬÈÏֵΪgetdate()¡£Óû§ÔÚдÈë¼Ç¼ʱ£¬Õâ¸öÁÐ×Ô¶¯Ð´È뵱ʱµÄʱ¼ä£¬Ê±¼ä¾«È·µ½ºÁÃë¡£¼´Ê¹ÕâÑù£¬ÎªÁ˱ÜÃâ¿ÉÄÜÐÔºÜСµÄÖغϣ¬»¹ÒªÔÚ´ËÁÐÉÏ´´½¨UNIQUEÔ¼Êø¡£½«´ËÈÕÆÚÁÐ×÷Ϊ¾Û¼¯Ë÷ÒýÁС£
¡¡¡¡ÓÐÁËÕâ¸öʱ¼äÐ;ۼ¯Ë÷ÒýÁÐÖ®
Ïà¹ØÎĵµ£º
1.Óòéѯ·ÖÎöÆ÷ÖØÃüÃû
exec sp_rename ÔÃû³Æ, ÐÂÃû³Æ
sp_rename ÊÇ SQL Server™ ×Ô´øµÄÒ»¸ö´æ´¢¹ý³Ì£¬ÓÃÓÚ¸ü¸Äµ±Ç°Êý¾Ý¿âÖÐÓû§´´½¨µÄ¶ÔÏóµÄÃû³Æ£¬Èç±íÃû¡¢ÁÐ±í¡¢Ë÷ÒýÃûµÈ¡£
2.ÓÃÆóÒµ¹ÜÀíÆ÷ÖØÃüÃû
ÔÚ±íÉϵãÓÒ¼ü->“ËùÓÐÈÎÎñ”->“¹ÜÀí´¥·¢Æ÷”£¬Ñ¡ÖÐËùÒªÖØÃüÃûµÄ´¥·¢Æ÷£¬Ð޸Ĵ¥·¢Æ÷Óï ......
1.²éÕÒÖظ´Êý¾Ý±íµÄidÒÔ¼°Öظ´Êý¾ÝµÄÌõÊý
select max(id) as nid,count(id) as Öظ´ÌõÊý from tableName
group by linkname Having Count(*) > 1
2.²éÕÒÖظ´Êý¾Ý±íµÄÖ÷¼ü
select max(id) as nid from tableName
group by linkname Having Count(id) > 1
3.ɾ³ýÖظ´µÄÊý¾Ý
delete from table ......
¹ØÓÚSQL Prompt
µÄÆƽâÎÄÕÂÔ°×ÓÀïÒѾÓв»ÉÙÈË·¢¹ýÁË¡£Æƽâ˼·ÎÒÒ²²»ÏëÖظ´£¬²»ÖªµÀµÄ¿ÉÒԲο¼£ºhttp://www.cnblogs.com/jintan/archive/2008/06/16/1223282.html
¹Ù·½ÏÂÔصØÖ·ÊÇ£ºhttp://downloads.red-gate.com/SQLToolbelt.exe
½ÓÏÂÀ´ÎÒ¾Í˵˵¾ßÌåÔõô×ö°É¡£ÎÒ¾Í˵˵×î¼òµ¥×îɵ¹ÏµÄ×ö·¨£¬²»ÐèÒª¶®ILÕÕÑùÆƽ⣡
× ......
´Ó×òÌ쿪ʼ¾ÍÒ»Ö±ÔÚÍøÉϲéÕÒÊý¾Ý¿âΪSQL server 2000 µÄJSP¿ª·¢»·¾³µÄ´î½¨£¬µ½ÏÖÔÚΪֹÖÕÓÚÄܹ»Õý³£Áª½Ó²¢·ÃÎÊ¡£ÒÔÏÂÊǴµÄ²½Ö裺
1¡¢´ÓÍøÉÏÏÂÔØÒ»¸öSQL server 2000 ¸öÈË°æµÄ°²×°°ü£¬°´ÕÕÌáʾ²Ù×÷£¬µ±ÔÚÉí·ÖÑé֤ʱ£¬Ñ¡Ôñ»ìºÏģʽ£¬Óû§saµÄÃÜÂë¿ÉÒÔΪ¿Õ£¬Ò²¿ÉÒÔ²»Îª¿Õ¡£
2¡¢´ÓÍøÉÏÏÂÔØÒ»¸öSQ ......
--ÉèÖÃÊý¾Ý¿âÊä³ö£¬Ä¬ÈÏΪ¹Ø±Õ£¬Ã¿´Îдò¿ª´°¿Ú¶¼ÒªÖØÐÂÉèÖÃ
set serveroutput on
--µ÷Óà °ü º¯Êý ²ÎÊý
execute dbms_output.put_line('hello world');
--»òÕßÓÃcallµ÷Óã¬Ï൱ÓÚjavaÖеĵ÷ÊÔ³ÌÐò´ò×®
call d ......