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

OracleÀ©Õ¹PL/SQL¼ò½é(Áù)

8.    bulk collect /forall
ʹÓÃbulk collect¿ÉÒԳɿéµØ¶ÁÈ¡Êý¾Ý£¬Ëü¿ÉʹSQLÒýÇæÔÚ·µ»ØÊä³ö½á¹û¸øPL/SQLÒýÇæ֮ǰ´óÅú°ó¶¨Êä³ö¼¯ºÏ¡£ÕâÑù¿ÉÒÔÒ»´ÎÐԵذÑÊý¾Ý¶¯Ì¬µØ×°Ôص½¼¯ºÏÖУ¬µ«bulk collectÐèÒª´óÁ¿ÄÚ´æ¡£bulk collect¿ÉÓÃÓÚselect into¡¢fetch intoºÍreturning intoÓï¾äÖС£
¡ñ    select intoÖÐʹÓÃbulk collect
declare
  type t_email is table of employees.email%type;
  v_email_list t_email;
begin
  select email bulk collect
    into v_email_list
    from employees
   where department_id = 50;
  dbms_output.put_line('»ñÈ¡emailµØÖ·Êý£º' || v_email_list.count);
end;
/
»ñÈ¡emailµØÖ·Êý£º45
¡ñ    fetch into ÖÐʹÓÃbulk collect
declare
  type t_emp is table of employees%rowtype;
  v_emp_list t_emp;
  cursor c_emp is
    select * from employees where department_id = 50;
begin
  open c_emp;
  --ÔÚfetch intoÖÐʹÓÃbulk collect
  fetch c_emp bulk collect
    into v_emp_list;
  dbms_output.put_line('»ñÈ¡¹ÍÔ±×ÜÊý£º' || v_emp_list.count);
end;
/
»ñÈ¡¹ÍÔ±×ÜÊý£º45
¡ñ    ÔÚreturning intoÖÐʹÓÃbulk collect
ͨ¹ýʹÓÃreturning×Ó¾äbulk collect¿É·µ»ØÖµ¸øµ÷Óùý³Ì£¬²»ÐèÒª¶îÍâ»ñÈ¡fetchÓï¾ä¡£
--´´½¨²âÊÔ±í
create table emptemp as select * from employees where department_id=50;
--Ö´Ðйý³Ì
declare
  type t_id_list is table of number;
  type t_name_list is table of varchar2(32);
  ids   t_id_list;
  names t_name_list;
begin
  delete from emptemp
   where commission_pct is null
  returning employee_id, first_name bulk collect into ids, names;
  dbms_output.put_line('Deleted ' || sql%rowcount || ' rows:');
  for i in ids.first .. ids.last loop
    dbms_output.put_line('Employees #' || ids(i) || ': ' || names(i));
  end loop;
  commit;
exception
  when others then
    rollback;
end;


Ïà¹ØÎĵµ£º

OracleϵÁУºÍ¼Æ¬µÄ´æ´¢

 OracleϵÁУºÍ¼Æ¬µÄ´æ´¢
Ò»£ºÊ²Ã´ÊÇ´ó¶ÔÏ󣬴ó¶ÔÏó»ù±¾²Ù×÷£¿
 ²Î¼ûÎÒµÄBLOG£ºOracleϵÁУºLOB´ó¶ÔÏó´¦Àí
 http://blog.csdn.net/qfs_v/archive/2008/05/21/2464599.aspx
 
¶þ£¬Í¼Æ¬µÄ´æ´¢»ò¶þ½øÖÆÎļþµÄ´æ´¢
 1£¬ÏȲåÈëÆÕͨÊý¾Ý£¬Óöµ½´ó¶ÔÏóÁÐʹÓÃempty_blob()¹¹Ôì¿ÕµÄÖ¸Õë¡£
  Àý× ......

Oracle ±í¿Õ¼ä»ù±¾²Ù×÷

 
1. ²éѯÊý¾Ý¿âÏÖÔڵıí¿Õ¼ä
select tablespace_name, file_name, sum(bytes)/1024/1024 table_size from dba_data_files group by tablespace_name,file_name;
 
2. ½¨Á¢±í¿Õ¼ä
CREATE TABLESPACE data01 DATAFILE '/oracle/ ......

OracleµÄOpenWorld:ÁªÊÖSun¶ÔÕ½IBM

 ½ñÄêµÄOracleÈ«Çò´ó»áÓÚ10ÔÂ11ÈÕ£­15ÈÕÔÚÃÀ¹ú¾É½ðɽµÄMosconeÖÐÐÄÒѾ­À­¿ªÐòÄ»ÁË¡£
¡¡¡¡ Oracle¶ÔSun¹«Ë¾µÄ³¤Æڼƻ®ÎÞÒÉÊDZ¾´ÎOOW´ó»áµÄ½¹µã¡£µ«ÔÚ̸ÂÛÕâ¸ö»°Ìâ֮ǰ£¬ÎÒÃÇ×¼±¸ÁËÒ»×é´ó»áµÄÓÐȤÊý¾Ý£¬ÏÈÈôó¼Ò¶Ô±¾´Î´ó»áÓиöÕûÌåµÄÓ¡Ïó¡£
¡¡¡¡ÓйØÕû¸ö´ó»áµÄÊý×Ö£º
¡¡¡¡· ½ü4.3ÍòÈ˵½»á
¡¡¡¡· ΪÃÀ¹ ......

OracleÍⲿ±íСÀý

1)½¨Á¢²Ù×÷ϵͳĿ¼e:\test£¬×¼±¸Êý¾ÝÎļþdept.txt²¢ÖÃÓÚe:\testÖ®ÏÂ
"10","ACCOUNTING","NEW
YORK"
"20","RESEARCH","DALLAS"
"30","SALES","CHICAGO"
"40","OPERATIONS","BOSTON"
2)´´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ