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

Ìá¸ß SQL ÐÔÄܵķ½·¨

ÓÐʱ£¬ ΪÁËÈÃÓ¦ÓóÌÐòÔËÐеøü¿ì£¬Ëù×öµÄÈ«²¿¹¤×÷¾ÍÊÇÔÚÕâÀï»òÄÇÀï×öһЩºÜСµ÷Õû¡£°¡£¬µ«¹Ø¼üÔÚÓÚÈ·¶¨ÈçºÎ½øÐе÷Õû£¡³ÙÔçÄú»áÓöµ½ÕâÖÖÇé¿ö£ºÓ¦ÓóÌÐòÖÐµÄ SQL ²éѯ²»ÄÜ°´ÕÕÄúÏëÒªµÄ·½Ê½½øÐÐÏìÓ¦¡£ËüҪô²»·µ»ØÊý¾Ý£¬ÒªÃ´ºÄ·ÑµÄʱ¼ä³¤µÃ³öÆæ¡£Èç¹ûËü½µµÍÁ˱¨¸æ»òÄúµÄÆóÒµÓ¦ÓóÌÐòµÄËٶȣ¬Óû§±ØÐëµÈ´ýµÄʱ¼ä¹ý³¤£¬ËûÃǾͻáºÜ²»ÂúÒâ¡£¾ÍÏñÄúµÄ¸¸Ä¸²»ÏëÌýÄú½âÊÍΪʲôÔÚÉî¸ü°ëÒ¹²Å»ØÀ´Ò»Ñù£¬Óû§Ò²²»»áÌýÄã½âÊÍΪʲô²éѯºÄ·ÑÕâô³¤Ê±¼ä¡££¨“¶Ô²»Æð£¬ÂèÂ裬ÎÒʹÓÃÁËÌ«¶àµÄ LEFT JOIN¡£”£©Óû§Ï£ÍûÓ¦ÓóÌÐòÏìӦѸËÙ£¬ËûÃǵı¨¸æÄܹ»ÔÚ˲¼äÖ®ÄÚ·µ»Ø·ÖÎöÊý¾Ý¡£¾ÍÎÒ×Ô¼º¶øÑÔ£¬Èç¹ûÔÚ Web ÉϳåÀËʱij¸öÒ³ÃæÒªºÄ·ÑÊ®¶àÃë²ÅÄܼÓÔØ£¨ºÃ°É£¬ÎåÃë¸üʵ¼ÊһЩ£©£¬ÎÒÒ²»áºÜ²»ÄÍ·³¡£
ΪÁ˽â¾öÕâЩÎÊÌ⣬ÖØÒªµÄÊÇÕÒµ½ÎÊÌâµÄ¸ùÔ´¡£ÄÇô£¬´ÓÄÄÀ↑ʼÄØ£¿¸ù±¾Ô­Òòͨ³£ÔÚÓÚÊý¾Ý¿âÉè¼ÆºÍ·ÃÎÊËüµÄ²éѯ¡£ÔÚ±¾ÔµÄרÀ¸ÖУ¬ÎÒ½«½²ÊöËÄÏî¼¼Êõ£¬ÕâЩ¼¼Êõ¿ÉÓÃÓÚÌá¸ß»ùÓÚ SQL Server? µÄÓ¦ÓóÌÐòµÄÐÔÄÜ»ò¸ÄÉÆÆä¿ÉÉìËõÐÔ¡£ÎÒ½«×Ðϸ˵Ã÷ LEFT JOIN¡¢CROSS JOIN µÄʹÓÃÒÔ¼° IDENTITY ÖµµÄ¼ìË÷¡£Çë¼Çס£¬¸ù±¾Ã»ÓÐÉñÆæµÄ½â¾ö·½°¸¡£µ÷ÕûÄúµÄÊý¾Ý¿â¼°Æä²éѯÐèÒªÕ¼ÓÃʱ¼ä¡¢½øÐзÖÎö£¬»¹ÐèÒª´óÁ¿µÄ²âÊÔ¡£ÕâЩ¼¼Êõ¶¼Òѱ»Ö¤Ã÷ÐÐÖ®ÓÐЧ£¬µ«¶ÔÄúµÄÓ¦ÓóÌÐò¶øÑÔ£¬¿ÉÄÜÆäÖÐһЩ¼¼Êõ±ÈÁíһЩ¼¼Êõ¸üÊÊÓá£
´Ó INSERT ·µ»Ø IDENTITY 
ÎÒ¾ö¶¨´ÓÓöµ½Ðí¶àÎÊÌâµÄÄÚÈÝÈëÊÖ£ºÈçºÎÔÚÖ´ÐÐ SQL INSERT ºó¼ìË÷ IDENTITY Öµ¡£Í¨³££¬ÎÊÌâ²»ÔÚÓÚÈçºÎ±àд¼ìË÷ÖµµÄ²éѯ£¬¶øÔÚÓÚÔÚÄÄÀïÒÔ¼°ºÎʱ½øÐмìË÷¡£ÔÚ SQL Server ÖУ¬ÏÂÃæµÄÓï¾ä¿ÉÓÃÓÚ¼ìË÷ÓÉ×îÐÂÔڻÊý¾Ý¿âÁ¬½ÓÉÏÔËÐÐµÄ SQL Óï¾äËù´´½¨µÄ IDENTITY Öµ£º
SELECT @@IDENTITYÕâ¸ö SQL Óï¾ä²¢²»¸´ÔÓ£¬µ«ÐèÒª¼ÇסµÄÒ»µãÊÇ£ºÈç¹ûÕâ¸ö×îÐ嵀 SQL Óï¾ä²»ÊÇ INSERT£¬»òÕßÄúÕë¶Ô·Ç INSERT SQL µÄÆäËûÁ¬½ÓÔËÐÐÁË´Ë SQL£¬Ôò²»»á»ñµÃÆÚÍûµÄÖµ¡£Äú±ØÐëÔËÐÐÏÂÁдúÂë²ÅÄܼìË÷½ô¸úÔÚ INSERT SQL Ö®ºóÇÒλÓÚͬһÁ¬½ÓÉ쵀 IDENTITY£¬ÈçÏÂËùʾ£º
INSERT INTO Products (ProductName) VALUES ('Chalk')
SELECT @@IDENTITYÔÚÒ»¸öÁ¬½ÓÉÏÕë¶Ô Northwind Êý¾Ý¿âÔËÐÐÕâЩ²éѯ½«·µ»ØÒ»¸öÃû³ÆΪ Chalk µÄвúÆ·µÄ IDENTITY Öµ¡£ËùÒÔ£¬ÔÚʹÓà ADO µÄ Visual Basic? Ó¦ÓóÌÐòÖУ¬¿ÉÒÔÔËÐÐÒÔÏÂÓï¾ä£º
Set oRs = oCn.Execute("SET NOCOUNT ON;INSERT INTO Products _
(ProductName) VALUES ('Chalk');SELECT @@IDENTITY")
lProductID = oRs(0)´Ë´úÂë¸æËß SQL


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

×î½üµÄÁ½ÌõsqlЧÂÊÓÅ»¯ÐĵÃ

µÚÒ»Ìõ£º
select * from where field in (1,2,3)   ÕâÖÖд·¨Ó¦¸ÃÉáÆúÁË£¬¶øÓ¦¸ÃÕâÑùд£º
select * from table where field = 1 or field = 2 or field = 3 
ΪʲôÄØ£¿
·²ÊÂÖ»ÓÐ×ö¹ý²ÅÖªµÀ£¬×Ô¼º½¨¸ö±í£¬²åÈë10WÌõ²âÊÔÊý¾Ý£¬ÓÃsql²âÊÔһϱãÖª£¬ÒòΪ¹¤×÷±ãÀû£¬ÎÒÔÚ²úÆ·»úºÍÍâÍø²âÊÔ»ú¶¼ÒѾ­²âÊÔ¹ý£ ......

¡¾×ª¡¿sql½âÎö²½Ö裬Ӳ½âÎöºÍÈí½âÎö





ÎÒÃǶ¼ÖªµÀÔÚOracleÖÐÿÌõSQLÓï¾äÔÚÖ´ÐÐ֮ǰ¶¼ÐèÒª¾­¹ý½âÎö£¬ÕâÀïÃæÓÖ·ÖΪÈí½âÎöºÍÓ²½âÎö¡£ÔÚOracleÖдæÔÚÁ½ÖÖÀàÐ͵ÄSQLÓï¾ä£¬Ò»ÀàΪ
DDLÓï¾ä£¨Êý¾Ý¶¨ÒåÓïÑÔ£©£¬ËûÃÇÊÇ´ÓÀ´²»»á¹²ÏíʹÓõģ¬Ò²¾ÍÊÇÿ´ÎÖ´Ðж¼ÐèÒª½øÐÐÓ²½âÎö¡£»¹ÓÐÒ»Àà¾ÍÊÇDMLÓï¾ä£¨Êý¾Ý²Ù×ÝÓïÑÔ£©£¬ËûÃÇ»á¸ù¾ ......

¡¾×ª¡¿Oracle SQLÐÔÄÜÓÅ»¯¼¼ÇÉ´ó×ܽá

£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯
Æ÷ÖÐÓÐЧ)£º
   
Oracle
µÄ
½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving
table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£¼ÙÈçÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ,
ÄÇ¾Í ......

SQL SERCER ±í×Ö¶ÎÐÞ¸Ä ×ܽá

ÕâÁ½ÌìÑо¿ÁËSQL SERVERµÄ×Ö¶ÎÐÞ¸Ä.ÓÐһЩÐĵÃ,д³öÀ´ÎªÈÕºó²Î¿¼:
1,ɾ³ý×Ö¶Î: ALTER TABLE [tablename] DROP COLUMN [fieldname]
ɾ³ýµÄʱºò¸Ã×ֶαØÐëûÓб»ÈκÎÍâ¼üÒýÓÃ,ûÓÐÈκÎÔ¼Êø.
2,ɾ³ýÔ¼Êø: ALTER TABLE [tablename] DROP CONSTRAINT constraint_name
ɾ³ýÔ¼ÊøÊÇÔ¼ÊøÃû²»¿É¼Óµ¥ÒýºÅ.
3,Ôö¼ÓĬÈÏÖµÔ¼Êø: ALT ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ