±¾ÎÄÀ´×Ôhttp://www.cnblogs.com/rootq/articles/1177562.html
Oracle Êý¾Ý¿âµÄ°ó¶¨±äÁ¿ÌØÐÔ¼°Ó¦ÓÃ
¹Ø¼ü´Ê:
°ó¶¨±äÁ¿(binding variable),¹²Ïí³Ø(shared buffer pool), SGA(system global area);
ÔÚ¿ª·¢Ò»¸öÊý¾Ý¿âϵͳǰ,ÓÐ˶ÔOracle ϵͳÁ˽âºÜ¶à,ÓÈÆäÊÇËüµÄÌØÐÔ,ºÃÏóºÜÉÙ°É;¶Ô³õѧÕßÀ´½²,Õâ¸üÊDz»¿ÉÄܵÄÊÂÇé;½ö½ö¼òµ¥ÕÆÎÕÁËSQLµÄд·¨,¾Í¿ªÊ¼ÁËÊý¾Ý¿âµÄ¿ª·¢,Æä½á¹ûÖ»ÄÜÊÇ¿ª·¢Ò»¸öûÓÐЧÂÊ,ҲûÓпÉÀ©Õ¹µÄϵͳ;
Òò´Ë,ÎÒдÕâ¸öÖ÷ÌâÒ²ÊÇÏ£ÍûÈôó¼Ò¸ü¶àµØÕÆÎÕOracleÊý¾Ý¿âµÄÌØÐÔ,´Ó¶øÔڼܹ¹Ò»¸öÐÂϵͳʱ,ÄÜ¿¼ÂÇϵͳµÄ¿ÉÀ©Õ¹,¿ÉÉìËõÐÔ,Ò²¼æ¹ËϵͳµÄЧÂʺÍÎȶ¨;
ʹÓð󶨱äÁ¿ÊÇOracleÊý¾Ý¿âµÄÌØÐÔÖ®Ò»;ÓÚÊÇ´ó¼ÒÒªÎÊ,ΪʲôʹÓÃ,ÔõÑùʹÓÃ,ËüµÄʹÓÃÏÞÖÆÌõ¼þÊÇʲô?ÎһᰴÕÕÕâÑùµÄÏ뷨ȥ½â´ð´ó¼ÒµÄÒÉÎÊ,ÎÒÒ²»áÒÔ¾ÙÀý×ӵķ½Ê½À´»Ø´ðÕâЩÎÊÌâ;
1. ΪʲôʹÓð󶨱äÁ¿?
ÕâÊǽâ¾öOracleÓ¦ÓóÌÐò¿ÉÉìËõÐÔµÄÒ»¸ö¹Ø¼ü»·½Ú;¶øOracleµÄ¹²Ïí³Ø¾Í¾ö¶¨ÁË¿ª·¢ÈËÔ±±ØÐëʹÓð󶨱äÁ¿;Èç¹ûÏëÒªOracle ÔËÐмõÂý,ÉõÖÁÍêÈ«ÖÕÖ¹,ÄǾͿÉÒÔ²»Óð󶨱äÁ¿;
ÕâÀï¾ÙÀý˵Ã÷ÉÏÊöÎÊÌâ;
ΪÁ˲éѯһ¸öÔ±¹¤´úºÅÊÇ123,Äã¿ÉÒÔÕâÑù²éѯ:
select * from emp where empno=’123’;
ÄãÒ²¿ÉÒÔÕâÑù²éѯ:
select * from emp where empno=:empno;
ÏóÎÒÃÇÍù³£Ò»Ñù,Äã²éѯԱ¹¤’123’Ò»´ÎÒÔºó,ÓпÉÄÜÔÙÒ²²»ÓÃ;½Ó×ÅÄãÓпÉÄܲéѯԱ¹¤’456’,È»ºó²éѯ’789’µÈµÈ;Èç¹û²éѯʹÓÃÏóµÚÒ»¸ö²éѯÓï¾ä,Äãÿ´Î²éѯ¶¼ÊÇÒ»¸öеIJéѯ(ÎÒÃǽÐËüÓ²±àÂëµÄ²éѯ·½·¨);Òò´Ë,Oracleÿ´Î±ØÐë·ÖÎö,½âÎö,°²È«¼ì²é, ÓÅ»¯µÈµÈ;
µÚ¶þ¸ö²éѯÓï¾äÌṩÁ˰󶨱äÁ¿:empno,ËüµÄÖµÔÚ²éѯִÐÐʱÌṩ,²éѯ¾¹ýÒ»´Î±àÒëºó,²éѯ·½°¸´æ´¢ÔÚ¹²Ïí³ØÖÐ,¿ÉÒÔÓÃÀ´¼ìË÷ºÍÖØÓÃ;ÔÚÐÔÄܺÍÉìËõÐÔ·½Ãæ,ÕâÁ½ÕߵIJîÒìÊǾ޴óµÄ,ÉõÖÁÊǾªÈ˵Ä;ͨË׵㽲,¾Í²»ÊÇÒ»¸ö¼¶±ð;
µÚÒ»¸ö²éѯʹÓõÄƵÂÊÔ½¸ß,ËùÏûºÄµÄϵͳӲ¼þ×ÊÔ´Ô½´ó,´Ó¶ø½µµÍÁËÓû§µÄʹÓÃÊýÁ¿;ËüÒ²»á°ÑÓÅ»¯ºÃµÄÆäËü²éѯÓï¾ä´Ó¹²Ïí³ØÖÐÌß³ö;¾ÍÏóÒ»¸öÀÏÊó»µÁËÒ»¹øÌÀËƵÄ,ϵͳµÄÕûÌåÐÔÄܽµµÍ; ¶øÖ´Ðа󶨱äÁ¿,Ìá½»Ïàͬ¶ÔÏóµÄÍêÈ«ÏàͬµÄ²éѯµÄÓû§(Õâ¾ä»°,´ó¼ÒÌýÆðÀ´±È½ÏÄÑÀí½â,ËæºóÎÒ»á¸ø³öÏêϸµÄ½âÊÍ),Ò»´ÎÐÔʹÓþͿÉÖظ´Ê¹ÓÃ,ÆäЧÂʲ»ÑÔ¶úÓï; ´ò¸öÐÎÏóµÄ±ÈÓ÷À´Ëµ,µÚÒ»¸ö²éѯ¾ÍÏóÒ»´ÎÐÔʹÓõĿê×Ó,¶øµÚ¶þ¸ö²éѯÏóÊÇÌú¿ê×Ó,ֻҪϴ¸É¾»,ÕÅÈýÀîËĶ¼ÄÜÓÃ,ºÏÀíÓÐЧµØʹÓÃÁË×ÊÔ´;
ÏÂÃæ¾ÙÀý×ÓÈ¥ÏêϸÂÛÖ¤ÉÏÊöµÄÎÊÌâ,²»Ê¹Óð󶨱äÁ¿ÎªÉú²¡×´¿ö:
ÕâÊÇÒ»¸öÎ