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

sql²éѯÓï¾äÖÐ inºÍ existsµÄÇø±ðÓëÐÔÄܱȽÏ

¶ÔInºÍexistsµÄÐÔÄܽøÐбȽϣ¬Ê×ÏÈÒªÖªµÀËüÃÇÁ½ÕßµÄÇø±ð¡£
in: È·¶¨¸ø¶¨µÄÖµÊÇ·ñÓë×Ó²éѯÖеÄÖµ»òÁбíÖеÄÖµÏàÆ¥Åä¡£
exists: Ö¸¶¨Ò»¸ö×Ó²éѯ£¬¼ì²âÐÐÊÇ·ñ´æÔÚ¡£
¿É·ÖÎöËüÃǵIJéѯÓï¾äÀ´µÃ³öÕæÊµµÄ²î±ð:
in
±ÈÈçSelect * from t1 where x in ( select y from t2 )
Ö´ÐеĹý³ÌÏ൱ÓÚ:
select *
  from t1, ( select distinct y from t2 ) t2
where t1.x = t2.y;
exists
±ÈÈçselect * from t1 where exists ( select t2.z from t2 where y = x )
Ö´ÐеĹý³ÌÏ൱ÓÚ:
for t in ( select * from t1 )
   loop
      if ( exists ( select t2.z from t2 where y = t.x )
      then
         OUTPUT THE RECORD
      end if
end loop
´ÓÉÏÃæµÄÓï¾ä¿ÉÒÔ¿´³ö£¬¶Ôt1±í²»¿É±ÜÃâµÄ½øÐÐÁËÒ»´ÎÈ«ÅÌɨÃè
inºÍexists
in ÊǰÑÍâ±íºÍÄÚ±í×÷hash Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ­»·£¬Ã¿´ÎloopÑ­»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£
Ò»Ö±ÒÔÀ´ÈÏΪexists±ÈinЧÂʸߵÄ˵·¨ÊDz»×¼È·µÄ¡£
Èç¹û²éѯµÄÁ½¸ö±í´óСÏ൱£¬ÄÇôÓÃinºÍexists²î±ð²»´ó¡£
Èç¹ûÁ½¸ö±íÖÐÒ»¸ö½ÏС£¬Ò»¸öÊÇ´ó±í£¬Ôò×Ó²éѯ±í´óµÄÓÃexists£¬×Ó²éѯ±íСµÄÓÃin£º
ÀýÈ磺±íA£¨Ð¡±í£©£¬±íB£¨´ó±í£©
1£º
select * from A where cc in (select cc from B)
ЧÂʵͣ¬Óõ½ÁËA±íÉÏccÁеÄË÷Òý£»
select * from A where exists(select cc from B where cc=A.cc)
ЧÂʸߣ¬Óõ½ÁËB±íÉÏccÁеÄË÷Òý¡£
Ïà·´µÄ
2£º
select * from B where cc in (select cc from A)
ЧÂʸߣ¬Óõ½ÁËB±íÉÏccÁеÄË÷Òý£»
select * from B where exists(select cc from A where cc=B.cc)
ЧÂʵͣ¬Óõ½ÁËA±íÉÏccÁеÄË÷Òý¡£
not in ºÍnot exists
Èç¹û²éѯÓï¾äʹÓÃÁËnot in ÄÇôÄÚÍâ±í¶¼½øÐÐÈ«±íɨÃ裬ûÓÐÓõ½Ë÷Òý£»
¶ønot extsts µÄ×Ó²éѯÒÀÈ»ÄÜÓõ½±íÉϵÄË÷Òý¡£
ËùÒÔÎÞÂÛÄǸö±í´ó£¬ÓÃnot exists¶¼±Ènot inÒª¿ì¡£ 
 


Ïà¹ØÎĵµ£º

SQL Server³£ÓÃϵͳ´æ´¢¹ý³Ì

--ÁгöSQL ServerʵÀýÖеÄÊý¾Ý¿â
sp_databases
--·µ»ØSQL Server¡¢Êý¾Ý¿âÍø¹Ø»ò»ù´¡Êý¾ÝÔ´µÄÌØÐÔÃûºÍÆ¥ÅäÖµµÄÁбí
sp_server_info
--·µ»Øµ±Ç°»·¾³ÖеĴ洢¹ý³ÌÁбí
sp_stored_procedures
--·µ»Øµ±Ç°»·¾³Ï¿ɲéѯµÄ¶ÔÏóµÄÁÐ±í£¨ÈκοɳöÏÖÔÚ from ×Ó¾äÖеĶÔÏó£©
sp_tables
select * from sysobjects
---Ìí¼Ó»ò¸ü¸Ä ......

oracle10g SQL ¸ú×Ù

1.¼¤»îSQL¸ú×Ù
   ´Óoracle10gÒÔºóÌṩÁËÐµķ½·¨¼¤»îSQLµÄ¸ú×Ù£¬¼´ÊÇʹÓÃdbms_monitor°üÀ´¿ªÆô»ò¹Ø±ÕSQL¸ú×Ù¡£
   ֮ǰ¾É·½·¨ÊÇʹÓà alter session set events ..  »òÕßʹÓÃdbms_system.set_ev·½Ê½
   ʹÓÃdbms_monitor°ü¿ÉÒÔÔڻỰ£¬¿Í»§¶Ë£¬×é¼þÒÔ¼°Êý¾Ý¿âËĸö²ã¼¶¿ªÆôSQLµÄ¸ú×Ù¡ ......

LINQ to SQL ѧϰreference

http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx
1-9 parts are the most useful knowledge for you so far. ......

Oracle SQL DeveloperÓëPL/SQL Developer±È½Ï¡¾×ª¡¿

¸½:Oracle SQL Developer — À©Õ¹½»Á÷ÖÐÐÄ
http://www.oracle.com/technology/global/cn/products/database/sql_developer/files/extensions.htm
      ֮ǰ×÷Ϊһ¸öOracle Employee£¬È´×ÜÊÇÔÚʹÓÃPL/SQL Developer£¨¶øÇÒÊÇÆÆ½â°æ£©£¬ÕâʵÔÚÓÐЩ˵²»¹ýÈ¥£¬µ«ÊÇÈçºÎÕÒµ½Ò»¸öºÏÐijÃÊÖµÄÄܹ»Ô ......

ʹÓÃPL/SQL Developer¹¤¾ßµ¼ÈëexcelºÍµ¼³öexcel

µ¼³ö:
1.Ö´ÐÐ
select Óï¾ä²éѯ³öÐèÒªµ¼³öµÄÊý¾Ý.
2.ÔÚÊý¾ÝÁбíÖÐÓÒ¼ü,Ñ¡Ôñsave
results.±£´æÎª.csvÎļþ,È»ºóÒÑexcel·½Ê½´ò¿ª¾ÍOKÁË.¿ÉÒÔÁí´æÎªxsl¡£ÐèҪעÒâµÄÊÇÈç¹ûÁÐÄÚÈÝÊÇ´¿Êý×Ö
µÄ»°£¬µ¼³öʱ»á×Ô¶¯°ÑÇ°ÃæµÄ0È¥µô£¬ÏëÒªµ¼³öÍêÕûµÄÁÐÄÚÈÝ£¬×îºÃÕâÁеÄÄÚÈÝÆ´Ò»¸ö×Ö·ûÈ磺select  ‘#’||Column from ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ