Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sql´óÊý¾Ý²Ù×÷ÈçºÎÓÅ»¯

¾ßÌåҪעÒâµÄ£º  
1.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖжÔ×ֶνøÐÐ null ÖµÅжϣ¬·ñÔò½«µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺  
select id from t where num is null  
¿ÉÒÔÔÚnumÉÏÉèÖÃĬÈÏÖµ0£¬È·±£±íÖÐnumÁÐûÓÐnullÖµ£¬È»ºóÕâÑù²éѯ£º  
select id from t where num=0  
2.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖÐʹÓÃ!=»ò<>²Ù×÷·û£¬·ñÔò½«ÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃè¡£ÓÅ»¯Æ÷½«ÎÞ·¨Í¨¹ýË÷ÒýÀ´È·¶¨½«ÒªÃüÖеÄÐÐÊý,Òò´ËÐèÒªËÑË÷¸Ã±íµÄËùÓÐÐС£  
3.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖÐʹÓà or À´Á¬½ÓÌõ¼þ£¬·ñÔò½«µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺  
select id from t where num=10 or num=20  
¿ÉÒÔÕâÑù²éѯ£º  
select id from t where num=10  
union all  
select id from t where num=20  
4.in ºÍ not in Ò²ÒªÉ÷Óã¬ÒòΪIN»áʹϵͳÎÞ·¨Ê¹ÓÃË÷Òý,¶øÖ»ÄÜÖ±½ÓËÑË÷±íÖеÄÊý¾Ý¡£È磺  
select id from t where num in(1,2,3)  
¶ÔÓÚÁ¬ÐøµÄÊýÖµ£¬ÄÜÓà between ¾Í²»ÒªÓà in ÁË£º  
select id from t where num between 1 and 3  
5.¾¡Á¿±ÜÃâÔÚË÷Òý¹ýµÄ×Ö·ûÊý¾ÝÖУ¬Ê¹Ó÷ǴòÍ·×ÖĸËÑË÷¡£ÕâҲʹµÃÒýÇæÎÞ·¨ÀûÓÃË÷Òý¡£  
¼ûÈçÏÂÀý×Ó£º  
SELECT * from T1 WHERE NAME LIKE ‘%L%’  
SELECT * from T1 WHERE SUBSTING(NAME,2,1)=’L’  
SELECT * from T1 WHERE NAME LIKE ‘L%’  
¼´Ê¹NAME×ֶν¨ÓÐË÷Òý£¬Ç°Á½¸ö²éѯÒÀÈ»ÎÞ·¨ÀûÓÃË÷ÒýÍê³É¼Ó¿ì²Ù×÷£¬ÒýÇæ²»µÃ²»¶ÔÈ«±íËùÓÐÊý¾ÝÖðÌõ²Ù×÷À´Íê³ÉÈÎÎñ¡£¶øµÚÈý¸ö²éѯÄܹ»Ê¹ÓÃË÷ÒýÀ´¼Ó¿ì²Ù×÷¡£  
6.±ØҪʱǿÖƲéѯÓÅ»¯Æ÷ʹÓÃij¸öË÷Òý£¬ÈçÔÚ where ×Ó¾äÖÐʹÓòÎÊý£¬Ò²»áµ¼ÖÂÈ«±íɨÃè¡£ÒòΪSQLÖ»ÓÐÔÚÔËÐÐʱ²Å»á½âÎö¾Ö²¿±äÁ¿£¬µ«ÓÅ»¯³ÌÐò²»Äܽ«·ÃÎʼƻ®µÄÑ¡ÔñÍƳٵ½ÔËÐÐʱ£»Ëü±ØÐëÔÚ±àÒëʱ½øÐÐÑ¡Ôñ¡£È»¶ø£¬Èç¹ûÔÚ±àÒëʱ½¨Á¢·ÃÎʼƻ®£¬±äÁ¿µÄÖµ»¹ÊÇδ֪µÄ£¬Òò¶øÎÞ·¨×÷ΪË÷ÒýÑ¡ÔñµÄÊäÈëÏî¡£ÈçÏÂÃæÓï¾ä½«½øÐÐÈ«±íɨÃ裺  
select id from t where num=@num  
¿ÉÒÔ¸ÄΪǿÖƲéѯʹÓÃË÷Òý£º  
select id from t with(index(Ë÷ÒýÃû)) where num=@num  
7.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖжÔ×ֶνøÐ


Ïà¹ØÎĵµ£º

sql server ´´½¨±íʱΪÁÐÌí¼Ó˵Ã÷


IF NOT EXISTS (SELECT * from ::fn_listextendedproperty
(N'MS_Description' , N'SCHEMA',N'dbo',
N'TABLE',N'±íÃû', N'COLUMN',N'ÁÐÃû'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N'˵Ã÷ÄÚÈÝ' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'±íà ......

MySQLºÍSQL×ֶνضÌ©¶´

תÔØ×Ô£ºhttp://www.neatstudio.com/index-4.shtml
ÎÄÕÂÀ´×Ô¼Åįhacker,http://hi.baidu.com/isbx/blog/item
/08ef48547ef1ad58574e00bf.html:
µ±Ç°µÄWeb¿ª·¢ÕßÖп϶¨Óв»ÉÙÈËûÓÐ×¢Òâµ½×÷ÕßËùÌáµ½µÄÕâÁ½¸öÎÊÌâµÄ¡£
µÚÒ»¸öÎÊÌâÊÇÕâÑùµÄ£¬MySQLĬÈÏÓÐÒ»¸öÅäÖòÎÊý
max_packet_size£¬Õâ¸ö²ÎÊýÊÇÓÃÓÚÏÞÖÆMySQL¿Í»§¶ËºÍMy ......

Óà SqlÌí¼Óɾ³ý×ֶΣ¬ÅжÏ×Ö¶ÎÊÇ·ñ´æÔڵķ½·¨

http://www.cnblogs.com/dwjaissk/archive/2006/07/25/459476.aspx
Ôö¼Ó×Ö¶Î
alter table docdsp  add dspcode char(200)
ɾ³ý×Ö¶Î
ALTER TABLE
table_NAME DROP COLUMN column_NAME
ÐÞ¸Ä×Ö¶ÎÀàÐÍ
ALTER TABLE table_name 
ALTER COLUMN column_name new_data_type
¸ÄÃû
sp_rename
¸ü¸Äµ±Ç°Êý¾Ý¿âÖÐ ......

Oracle SQLÓï¾äÓÅ»¯·ÖÎö

¡¡²Ù×÷·ûÓÅ»¯
¡¡¡¡IN ²Ù×÷·û
¡¡¡¡ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ׶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£
¡¡¡¡µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊDZȽϵ͵ģ¬´ÓORACLEÖ´ÐеIJ½ÖèÀ´·ÖÎöÓÃINµÄSQLÓë²»ÓÃINµÄSQLÓÐÒÔÏÂÇø±ð£º
¡¡¡¡ORACLEÊÔͼ½«Æäת»»³É¶à¸ö±íµÄÁ¬½Ó£¬Èç¹ûת»»²»³É¹¦ÔòÏÈÖ´ÐÐINÀïÃæµÄ×Ó²éѯ£¬ÔÙ²éѯÍâ²ãµÄ±í¼Ç¼£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ