¡°ÓÅÐãʾÀý¡±: Oracle´úÂë¹æ³Ì
ÔÚPL/SQLÖÐʹÓÃÕóÁд¦ÀíÊÇÒ»¸öºÜºÃµÄ×ö·¨(È磬ʹÓÃbulk collectºÍforall)¡£ÅúÁ¿´¦ÀíÄܹ»´ó´ó¼õÉÙPL/SQLÓï¾äÖ´ÐÐÒýÇæµÄ»·¾³Çл»´ÎÊý£¬´Ó¶øÌá¸ßÆäÐÔÄÜ¡£
¡¡¡¡ÁíÒ»¸öÓÅÐãʾÀýÊÇ°Ñ´æ´¢¹ý³ÌÖеÄËùÓдúÂë·ÅÈëËø¶¨µÄÈí¼þ°üÖУ¬ÕâÑù¿ÉÒÔÉú³ÉÄ£¿éµ¥Ôª¡£°Ñ´æ´¢¹ý³Ì·ÅÈëÈí¼þ°üÀï¿ÉÒÔʵÏÖÏà¹Ø³ÌÐòºÍ¹¦ÄܵķÖ×é¡£µ±
µ¥¸ö°ü±»Ê¹Óã¬Õû¸öÈí¼þ°ü¶¼»áÔØÈëÄÚ´æÖÐ(ÄÚ´æ»áÆô¶¯Õû¸öÈí¼þ°ü?)£¬°Ñ´Åµú´æȡʱ¼ä¼õµ½×îÉÙ¡£Í¨¹ýÕâ¸ö·½·¨ÎÒÃÇͬÑù¿ÉÒÔ°ÑÕû¸öÓ¦ÓóÌÐò°üÔؽøÄÚ´æÖУ¬·À
Ö¹·¢ÉúÖØÐÂÔØÈëºÍ´úÂë½âÎö£¬´Ó¶ø¼õÉÙÑÏÖØÓ°ÏìÐÔÄܵĴúÂëµÝ¹é¡£
¡¡¡¡PL/SQL(ºÍSQL)µÄÁíÒ»¸öÓÅÐãʾÀýÊÇʹÓÃÊʵ±µÄ±äÁ¿ÀàÐÍ(µ±ÄãÐèÒªNUMBERʱ²»ÒªÊ¹ÓÃVARCHAR2£¬·´Ö®ÒàÈ»)¡£Ê¹Óò»Êʵ±µÄ±äÁ¿(ÓÃcharacter¸únumber½øÐбȽÏ)»áµ¼ÖÂÎÞÓÃË÷Òý¡£±£Ö¤±äÁ¿ÀàÐÍÕýÈ·µÄÒ»ÖÖ·½·¨¾ÍÊÇʹÓÃ%TYPE ºÍ%ROWTYPE¡£
¡¡¡¡»¹ÓоÍÊÇÓÀԶʹÓÃDBMS_PROFILER»òʹÓÃÏñQuest SoftwareµÄQuest Code Tester¹¤¾ßÀ´Ñé֤ѻ·Âß¼¡£DBMS_PROFILERÊÇOracleÌṩµÄÒ»¸öÈí¼þ°ü£¬Äܹ»Ê¹ÄãµÄ´úÂëÉú³É¶ÔÿÐÐÖ´ÐÐʱ¼ä¼°ËùÐèʱ¼äµÄ×·×Ù¡£Äã¿ÉÒÔÑé֤ѻ·Ö´ÐдÎÊýӦΪ×îÉÙ¡£
¡¡¡¡ÄãͬÑùÓ¦¸ÃÑéÖ¤Êʵ±µÄIF-THEN-ELSE½á¹¹¡£ÎÒµÄÒâ˼ÊÇÄãÓ¦¸Ã°Ñ×î³£ÓõÄÑ¡Ïî·ÅÔÚÇ°Ãæ(±ÈÈçexit test)¡£Õâ¸ö·½·¨Í¬ÑùʹÓÃÓÚCASE½á¹¹¡£
¡¡¡¡PL/SQL(ÒÔ¼°Java¡¢C¡¢C++ºÍÆäËûËùÓÐOracleÏà¹ØµÄ3GLs)ÖУ¬ÁíÒ»¸ö¸üΪÖØÒªµÄÓÅÐãʾÀýÊÇÊ×Ïȵ÷ÓÅSQL¡£¼´Ê¹ÊÇÊÀ½çÉÏÉè¼Æ×ÃܵijÌÐò£¬Èç¹ûÆäÖк¬ÓеÄSQLºÜ²îµÄ»°£¬ÔËÐÐÆðÀ´ÐÔÄÜÒ²»á²»ºÃ¡£QuestµÄSQL Optimizer¡¢Performance Analyzer¡¢TOADºÍSQL Navigator¶¼Äܹ»ÓÅ»¯SQL¡£
¡¡¡¡ÔÚ²âÊÔPL/SQL-SQL´úÂëµÄʱºò£¬Ó¦ÀûÓÃÄäÃûPL/SQL¿éÀ´±£Ö¤´¦Àí»·¾³µÄÏàËÆÐÔ¡£Èç¹ûÄãÔÚÒ»¸ö±ê×¼µÄSQL»·¾³ÀïÓÃÎÄ×Ö´úÌæ°ó¶¨±äÁ¿À´½øÐвâÊÔ£¬ÄãËùµÃµ½µÄÖ´Ðмƻ®»á²»Í¬ÓÚµ±ÄãʹÓÃÄäÃûPL/SQL¿éºÍ°ó¶¨±äÁ¿Ê±µÃµ½µÄÖ´Ðмƻ®£¬Òò´ËÄãµÄµ÷ÕûºÜ¿ÉÄܲ»ÄÜ»ñµÃºÜºÃµÄ½á¹û¡£Ê¹ÓÃQuest Code TesterÄܹ»±£Ö¤ÄãÄÜ»ñµÃÄãÏëÒªµÄ½á¹û¡£
¡¡¡¡»¹ÓÐÒ»¸öÁ¼ºÃµÄ±à³Ì×ö·¨ÊǺܺõØÀûÓÃÁÙʱ±íºÍPL/SQLË÷Òý±í¡£²»ÕýÈ·µØʹÓÔnormal”±í½øÐÐÁÙʱ´¢´æ»á½µµÍÐÔÄÜ£¬Òò´ËӦʹÓÃÁÙʱ±í¡£¶øµ±ÄÚ´æ¿Õ¼ä×ã¹»ÔËÐÐPL/SQL±íʱʹÓÃÁÙʱ±íÒ²»á´ó´ó½µµÍÐÔÄÜ¡£ÄãÒ²¿ÉÒÔÀûÓÃÊÓͼÀ´´´½¨Öмä½á¹ûµÄ»º´æ±í¡£
¡¡¡¡»¹ÓÐÒ»¸öºÜ¼òµ¥Ò×ÐеÄÓÅÐãʾÀýÊÇÔÚIN OUTºÍOUT±äÁ¿ÉÏÀûÓÃNOCOPY¡£ÔÚÒ»¸öʹÓÃIN OUT»òOUTµÄPL/SQL³ÌÐòÖУ¬Èç¹ûNOCOPY¹Ø¼ü×ÖûÓаüº¬ÔÚÆäÒ³Ê׵ıäÁ¿ÉùÃ÷ÖУ¬ËùÓеıäÁ¿¶¼»áÍ
Ïà¹ØÎĵµ£º
·½·¨Ò»£º
----------------------------------------------------------------
---Muti-row to line(col2row)
----------------------------------------------------------------
create or replace type str_tab is table of varchar2(20);
/
grant all on str_tab to public;
create public synonym str_tab for ......
2009-04-22 22:00
À´Ô´£ºÖйú
IT
ʵÑé
ÊÒ ×÷ÕߣºØýÃû
Oracle
¿Í
Ȥ
¶ËÓë·þ
Îñ
Æ÷¶ËµÄ
Á¬
½ÓÊÇͨ
¹ý
¿Í
Ȥ
¶Ë
·¢
³ö
Á¬
½Ó
Çë
Çó£¬ÓÉ·þ
Îñ
Æ÷¶Ë
¼à
ÌýÆ÷
¶Ô
¿Í
Ȥ
¶Ë
Á¬
½Ó
Çë
Çó
½ø
ÐкϷ¨
¼ì²é
£¬Èç¹û
Á¬
½Ó
Çë
ÇóÓÐЧ£¬
Ôò½ø
ÐÐ
Á¬
½Ó£¬·ñ
Ôò
¾Ü
¾ø¸ÃÁ¬
½Ó¡£ ......
½ñÌìÖØÐÂÕûÀíµçÄÔ£¬ÕÒµ½Ò»¸öÎļþ£¬¿´ÁËÏÂÈÕÆÚ£¨2006.11.3£© £¬Å²»Ð¡ÐÄÔÙ¶ªÁË£¬´æµ½ÍøÉÏÀ´É¹É¹¡£
SQL ÓïÑÔ·ÖÀࣺ
1 DDL£¨Êý¾Ý¶¨Òå £©ÓÃÓÚ´´½¨ºÍ¶¨ÒåÊý¾Ý¿â¶ÔÏ󣬲¢ÇÒ½«¶ÔÕâЩ¶ÔÏóµÄ¶¨Òå±£´æÔÚÊý¾Ý×ÖµäÖС£
creat table ´´½¨±í
alter table ÐÞ¸ ......
OracleÈëÃÅÊé¼®ÍƼö
Á´½Ó£ºhttp://www.eygle.com/archives/2006/08/oracle_fundbook_recommand.html
ºÜ¶àÅóÓÑÒªÎÒ°ïæÍƼöÒ»ÏÂOracleµÄÈëÃÅÊé¼®£¬Äܹ»Á˽âOracleµÄ»ù±¾¸ÅÄî¡¢»ù±¾ÖªÊ¶µÄÄÇÖÖ¡£
ÎÒ¾ÍÃâΪÆäÄÑ£¬ÍƼö¼¸±¾¡£
Ê×ÏÈÎÒÏëÇ¿µ÷µÄÒ»µãÊÇ£¬ÈκÎÒ»±¾ÏµÍ³µÄOracleÊé¼®Ö»ÒªÈÏÕæ¶ÁÏÂÀ´£¬¶¼»áÓв»´íµÄÊÕ»ñ£¬¶ÁÊé×î¼É»äµÄ ......
create or replace procedure p //ÓоÍÌæ»»£¬Ã»Óоʹ´½¨
is
cursor c is
select * from emp for update;
begin
for v_emp in c loop
if (v_emp.deptno =10) then
&nb ......