SQL——Êý¾ÝÍêÕûÐÔ
Ò»£®Êý¾ÝÍêÕûÐÔ
¾ÍÊÇΪÁË·ÀÖ¹Êý¾Ý¿âÖдæÔÚ²»·ûºÏÓïÒå¹æ¶¨µÄÊý¾Ý£¬ºÍ·ÀÖ¹ÒòÊäÈëÊä³ö´íÎó¶øÔì³ÉµÄÎÞЧ²Ù×÷»òÕß´íÎóÐÅÏ¢¶øÌá³öµÄ£¬Öƶ¨µÄһЩ¶ÔÔª×é¡¢ÊôÐÔºÍÓòµÄһЩԼÊøºÍ¹æ¶¨¡£
½â¾ö°ì·¨ÓÉ£º¹æÔò£¬Ä¬ÈÏÖµ£¬Ô¼ÊøºÍ´¥·¢Æ÷µÈ¡£
¶þ£®Ô¼Êø
ÓÃÓÚÔöÇ¿Êý¾ÝÍêÕûÐÔ£¬·ÀÖ¹ºÏ·¨Óû§Ê¹ÓÃÊý¾Ý¿âʱ£¬ÏëÊý¾Ý¿âÖÐÌí¼Ó²»·ûºÏÓïÒåµÄÊý¾Ý¡£Ô¼Êø·ÖΪÈýÖÖ£ºÓë±íÓйصÄÔ¼Êø£¬ÓòÔ¼Êø£¬¶ÏÑÔÔ¼Êø¡£
¡£Óë±íÓйصÄÔ¼Êø£ºÐÐÔ¼Êø£¬ÁÐÔ¼Êø¡£
¡£ÓòÔ¼Êø£ºÔÚÓò¶¨ÒåÖỶ¨ÒåµÄ£¬²¢ÇÒÓëÔÚÓòÖж¨ÒåµÄÈκÎÁж¼ÓйØϵµÄÒ»ÖÖÔ¼Êø¡£
¡£.¶ÏÑÔÔ¼Êø£ºÔÚ¶ÏÑÔ¶¨Òåʱ¶¨ÒåµÄÒ»ÖÖÔ¼Êø£¬¿ÉÒÔÓëÒ»¸ö»òÕ߶à¸ö±íÓйء£
ÏÂÃæÊÇDEFAULTÔ¼Êø£¬CHECKÔ¼Êø£¬PRIMARYKEYÔ¼Êø£¬UNIQUEÔ¼Êø£¬FOREIGN KEYÔ¼Êø£¬NOU NULLÔ¼Êø£¬ÁÐÔ¼Êø£¬±íÔ¼Êø¡£
1£®DEFAULTÔ¼Êø
Ö÷Òª¾ÍÊÇÕë¶Ô±íÖеÄij¸öÁУ¬´´½¨Ò»¸öĬÈÏÖµ£¬ÔÚÓû§²åÈëֵʱ£¬Èç¹ûûÓиø¶¨Öµ£¬ÄǾÍĬÈÏΪ´ËÖµ¡£
(1).´´½¨Êý×ÖÀàÐ͵ÄDEFAULTÔ¼Êø
Êý×ÖÀàÐÍÓУºÕûÊý£¨bigint , int , smallint , tinyint£©£¬¾«È·Êý×Ö£¨decimal[p( , s)] ,
numeric[p( , s]£©£¬¸¡µãÊý£¨float[(n)] , real£©£¬»õ±ÒÖµ£¨money , smallmoney£©¡£
¼ÙÉè±ígoods£¬ÊôÐÔ£ºgNO,gNAME,gCOUNT,gPRICE,gADDRESS,StartDate
ÏÖÔÚΪgCOUNTºÍgPRICE´´½¨Ä¬ÈÏÖµ£º
ALTER TABLE goods ADD DEFAULT 0 FOR gCOUNT;
ALTER TABLE goods ADD DEFAULT 0 FOR gPRICE;
ÊäÈëÒÔÏÂÓï¾ä£ºINSERT INTO goods (gNO,gNAME,gADDRESS) VALUES('1001','ë½í','¼ªÁÖ³¤´º','2010-1-20 15:25:30.120')¡£Ö´Ðгɹ¦ºó£¬ÔÚ²Á¿´Ò»Ï£¬Äã»á·¢ÏÖ½á¹ûÖÐgCOUNTºÍgPRICEÁеÄֵΪ0¡£
×¢Ò⣺ÔÚÖ´ÐвåÈëÓï¾äʱ£¬Ò»¶¨ÒªÁгö²åÈëµÄÁУ¬Òª²»È»Äã»áÓöµ½²åÈëÊý¾ÝÁÐÓë±íÊôÐÔÁв»Ò»ÖµĴíÎó¡£
(2).ÉèÖÃDEFAULTÈÕÆÚÐÍÔ¼Êø
Ϊgoods±íµÄ»õÎïµ½»õÈÕÆÚStartDateÉèÖÃĬÈÏֵΪϵͳµ±Ç°ÈÕÆÚ¡£
ALERT TABLE 
Ïà¹ØÎĵµ£º
ÅÅÃûº¯ÊýÊÇSQL Server2005мӵŦÄÜ¡£ÔÚSQL Server2005ÖÐÓÐÈçÏÂËĸöÅÅÃûº¯Êý£º
¡¡¡¡1.row_number
¡¡¡¡2.rank
¡¡¡¡3.dense_rank
¡¡¡¡4.ntile¡¡¡¡
¡¡¡¡ÏÂÃæ·Ö±ð½éÉÜÒ»ÏÂÕâËĸöÅÅÃûº¯ÊýµÄ¹¦Äܼ°Ó÷¨¡£ÔÚ½éÉÜ֮ǰ¼ÙÉèÓÐÒ»¸öt_table±í£¬±í½á¹¹Óë±íÖеÄÊý¾ÝÈçͼ1Ëùʾ£º
¡¡¡¡Í¼1
¡¡¡¡ÆäÖÐfield1×ֶεÄÀàÐÍÊÇint£¬field2×Ö¶ ......
Õý³£µÇ½sql*plusµÄ²½ÖèÈçÏ£º
sbdatabase*orcl-/home/oracle>sqlplus /nolog
SQL*Plus: Release 10.2.0.3.0 - Production on Sun May 9 19:50:24 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
SQL> conn hmsimis/test@orcl
Connected.
SQL>
¿ÉÒÔ¿´µ½Ç°ÃæµÄÌáʾ·ûÊÇSQL£¬ÏÖÔÚÏëÐ ......
UltraLite®J£ºBlackBerryÉÏÔËÐеÄСÊý¾Ý¿âºÍͬ²½ÒýÇæ
MobiLink £ºÔËÐÐÔÚ·þÎñÆ÷ÉÏÊý¾Ý¿âͬ²½·þÎñÆ÷£¬¿ÉÒÔ°ÑÉ豸ÉϵÄÊý¾Ýͬ²½µ½ºǫ́µÄ¡£°üº¬ÔÚSQL Anywhere 11ÀïÃæ¡£
SQL Anywhere ÊÇÒµÄÚÁìÏȵÄÒƶ¯ºÍǶÈëʽÊý¾Ý¿â£¬ÌṩÊý¾Ý¹ÜÀíºÍ½»»»¼¼Êõ£¬ÎªÒ»Ïß»·¾³ÖеÄÓ¦ÓóÌÐòÌṩ֧³Ö¡£
SQL Anywhere רΪ²»¾ß±¸ÏÖ³¡ IT Ö§³Ö¡¢Ô ......
vs2005ÖÐÎÞ·¨Á¬½ÓSQLÎÊÌâ
×î½üÔÚÑо¿ASP.NET£¬ÔÚ°²×°VS2005ºÍSQLÉÏ£¬ÎÊÌâ¶à¶à°¡£¬¿¨ÁËÎҺܶàÌ죬×îºóÔÚ²éÔÄÒ»¶Ñ×ÊÁϺÍÖØ×°ÎÞÊý´Îϵͳ֮ºó£¬ÖÕÓÚÑо¿³öΪʲôÎÒ²»ÄÜÁ¬½ÓÊý¾Ý¿âµÄÎÊÌâÁË£¬½â¾ö·½·¨ÈçÏ£º
¡¡¡¡(1)¿ªÊ¼->³ÌÐò->Microsoft SQL Server 2005->SQL Server 2005ÍâΧӦÓÃÅäÖÃÆ÷,ÔÚ´ò¿ªµÄ½çÃæµ¥»÷"·þÎñµÄÁ¬ ......
SQL 2005Ô¶³Ì·ÃÎʵÄÉèÖÃ
2009-02-27 08:13
1¡¢Ê×ÏÈ´ò¿ªSQL Server ÍâΧӦÓÃÅäÖÃÆ÷£¬µã»÷“·þÎñºÍÁ¬½ÓµÄÍâΧӦÓÃÅäÖÃÆ÷”£¬Ñ¡ÔñÊý¾Ý¿â→Ô¶³Ì·þÎñ£¬µãÉϱ¾µØÁ¬½ÓºÍÔ¶³ÌÁ¬½Ó£¬ÔÙµãÉÏͬʱʹÓÃtcp/ipºÍnamed pipes
2¡¢´ò¿ªSQL Server Configuration Manager£¬SQL Server 2005ÍøÂçÅäÖ㬽«TCP/IPÆôÓÃÁË¡£
3¡¢Ò» ......