ͨ¹ý·ÖÎöSQLÓï¾äµÄÖ´Ðмƻ®ÓÅ»¯SQL(ËÄ)
Î壺 ORACLEµÄÖ´Ðмƻ®
±³¾°ÖªÊ¶£ºÎªÁ˸üºÃµÄ½øÐÐÏÂÃæµÄÄÚÈÝÎÒÃDZØÐëÁ˽âһЩ¸ÅÄîÐÔµÄÊõÓ
¹²ÏísqlÓï¾ä
ΪÁ˲»Öظ´½âÎöÏàͬµÄSQLÓï¾ä(ÒòΪ½âÎö²Ù×÷±È½Ï·Ñ×ÊÔ´£¬»áµ¼ÖÂÐÔÄÜϽµ)£¬ÔÚµÚÒ»´Î½âÎöÖ®ºó£¬ORACLE½«SQLÓï¾ä¼°½âÎöºóµÃµ½µÄÖ´Ðмƻ®´æ·ÅÔÚÄÚ´æÖС£Õâ¿éλÓÚϵͳȫ¾ÖÇøÓòSGA(system global area)µÄ¹²Ïí³Ø(shared buffer pool)ÖеÄÄÚ´æ¿ÉÒÔ±»ËùÓеÄÊý¾Ý¿âÓû§¹²Ïí¡£Òò´Ë£¬µ±ÄãÖ´ÐÐÒ»¸öSQLÓï¾ä(ÓÐʱ±»³ÆΪһ¸öÓαê)ʱ£¬Èç¹û¸ÃÓï¾äºÍ֮ǰµÄÖ´ÐйýµÄijһÓï¾äÍêÈ«Ïàͬ£¬²¢ÇÒ֮ǰִÐеĸÃÓï¾äÓëÆäÖ´Ðмƻ®ÈÔÈ»ÔÚÄÚ´æÖдæÔÚ£¬ÔòORACLE¾Í²»ÐèÒªÔÙ½øÐзÖÎö£¬Ö±½ÓµÃµ½¸ÃÓï¾äµÄÖ´Ðз¾¶¡£ORACLEµÄÕâ¸ö¹¦ÄÜ´ó´óµØÌá¸ßÁËSQLµÄÖ´ÐÐÐÔÄܲ¢´ó´ó½ÚÊ¡ÁËÄÚ´æµÄʹÓá£Ê¹ÓÃÕâ¸ö¹¦ÄܵĹؼüÊǽ«Ö´ÐйýµÄÓï¾ä¾¡¿ÉÄܷŵ½ÄÚ´æÖУ¬ËùÒÔÕâÒªÇóÓдóµÄ¹²Ïí³Ø(ͨ¹ýÉèÖÃshared buffer pool²ÎÊýÖµ)ºÍ¾¡¿ÉÄܵÄʹÓð󶨱äÁ¿µÄ·½·¨Ö´ÐÐSQLÓï¾ä¡£
µ±ÄãÏòORACLE Ìá½»Ò»¸öSQLÓï¾ä£¬ORACLE»áÊ×ÏÈÔÚ¹²ÏíÄÚ´æÖвéÕÒÊÇ·ñÓÐÏàͬµÄÓï¾ä¡£ÕâÀïÐèҪעÃ÷µÄÊÇ£¬ORACLE¶ÔÁ½Õß²ÉÈ¡µÄÊÇÒ»ÖÖÑϸñÆ¥Å䣬Ҫ´ï³É¹²Ïí£¬SQLÓï¾ä±ØÐëÍêÈ«Ïàͬ(°üÀ¨¿Õ¸ñ,»»ÐеÈ)¡£
ÏÂÃæÊÇÅжÏSQLÓï¾äÊÇ·ñÓë¹²ÏíÄÚ´æÖÐijһSQLÏàͬµÄ²½Ö裺
1. ¶ÔËù·¢³öÓï¾äµÄÎı¾´®½øÐÐhashed¡£Èç¹ûhashÖµÓëÒÑÔÚ¹²Ïí³ØÖÐSQLÓï¾äµÄhashÖµÏàͬ£¬Ôò½øÐеÚ2²½£º
2.½«Ëù·¢³öÓï¾äµÄÎı¾´®£¨°üÀ¨´óСд¡¢¿Õ°×ºÍ×¢ÊÍ£©ÓëÔÚµÚ£±²½ÖÐʶ±ðµÄËùÓÐ
ÒÑ´æÔÚµÄSQLÓï¾äÏà±È½Ï¡£
ÀýÈ磺
SELECT * from emp WHERE empno = 1000;
ºÍÏÂÁÐÿһ¸ö¶¼²»Í¬
SELECT * from emp WHERE empno = 1000;
SELECT * from EMP WHERE empno = 1000;
SELECT * from emp WHERE empno = 2000;
ÔÚÉÏÃæµÄÓï¾äÖÐÁÐÖµ¶¼ÊÇÖ±½ÓSQLÓï¾äÖеģ¬½ñºóÎÒÃǽ«ÕâÀàsql³ÉΪӲ±àÂëSQL
»ò×ÖÃæÖµSQL
ʹÓð󶨱äÁ¿µÄSQLÓï¾äÖбØÐëʹÓÃÏàͬµÄÃû×ֵİ󶨱äÁ¿(bind variables) £¬
ÀýÈ磺
a. ¸Ã2¸ösqlÓï¾ä±»ÈÏΪÏàͬ
select pin , name from people where pin = :blk1.pin;
select pin , name from people where pin = :blk1.pin;
b. ¸Ã2¸ösqlÓï¾ä±»ÈÏΪ²»Ïàͬ
select pin , name from people where pin = :blk1.ot_ind;
select pin , name from people where pin = :blk1.ov_ind;
½ñºóÎÒÃǽ«ÉÏÃæµÄÕ
Ïà¹ØÎĵµ£º
/***************************************************
×÷Õߣºherowang(ÈÃÄãÍû¼ûÓ°×ÓµÄǽ£©
ÈÕÆÚ£º2009.12.19
×¢£º תÔØÇë±£Áô´ËÐÅÏ¢
&nb ......
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£©Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
orACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ ......
ÔÚWin7Ï°²×°SQL2005¿ª·¢°æ£¬°²×°SQL Native ClientʱÌáʾ°²×°Öжϣ¬Ã»ÓÐÔÚÒ⣬ȻºóÔÚ°²×°SQL ServerʱÓÖÌáʾ“[Microsoft][SQL Native Client]¿Í»§¶Ë²»Ö§³Ö¼ÓÃÜ.SQL Server °²×°³ÌÐòÎÞ·¨Á¬½Óµ½Êý¾Ý¿â·þÎñ½øÐзþÎñÆ÷ÅäÖÃ.”жÔØSQL Native ClientÖØа²×°£¬»¹ÊÇÖжϣ¬ÐÞ¸´£¬Ò²Öжϣ¬ÔÙжÔØ£¬ÇåÀí×¢²á±í£¬ÖØ× ......
¡¡SQLÖÐÓÐËÄÖÖ»ù±¾µÄDML²Ù×÷£ºINSERT£¬SELECT£¬UPDATEºÍDELETE¡£
INSERTÓï¾ä
¡¡¡¡Óû§¿ÉÒÔÓÃINSERTÓï¾ä½«Ò»ÐмǼ²åÈëµ½Ö¸¶¨µÄÒ»¸ö±íÖС£ÀýÈ磬Ҫ½«¹ÍÔ±John SmithµÄ¼Ç¼²åÈëµ½±¾ÀýµÄ±íÖУ¬¿ÉÒÔʹÓÃÈçÏÂÓï¾ä£º
¡¡¡¡INSERT INTO EMPLOYEES VALUES
¡¡¡¡ ('Smith','John','1980-06-10',
¡¡¡¡ 'Los Angles',16,45000);
¡¡ ......