Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 DATA GUARD

¡¾IT168¼¼ÊõÎĵµ¡¿
     DATA GUARDµÄ×îÖ÷ÒªµÄ¹¦ÄÜÊÇÈßÔÖ¡£µ±È»¸ù¾ÝÅäÖõIJ»Í¬£¬DATA GUARD»¹¿ÉÒԾ߱¸ÒÔÏÂÌØµã£º¸ß¿ÉÓá¢ÐÔÄÜÌáÉý¡¢Êý¾Ý±£»¤ÒÔ¼°¹ÊÕϻָ´µÈ¡£
    DATA GUARD¿ÉÒÔ·ÖΪÎïÀíSTANDBYºÍÂß¼­STANDBYÁ½ÖÖ¡£¶þÕßµÄ×î´ó²î±ðÔÚÓÚ£¬ÎïÀíSTANDBYÓ¦ÓõÄÊÇÖ÷¿âµÄ¹éµµÈÕÖ¾£¬¶øÂ ......

OracleϵÁУº¼Ç¼Record

 OracleϵÁУº¼Ç¼£¨Record£©
Ò»£¬Ê²Ã´ÊǼǼ£¨Record£©£¿
 Óɵ¥ÐжàÁеıêÁ¿¹¹³ÉµÄ¸´ºÏ½á¹¹¡£¿ÉÒÔ¿´×öÊÇÒ»ÖÖÓû§×Ô¶¨ÒåÊý¾ÝÀàÐÍ¡£×é³ÉÀàËÆÓÚ¶àάÊý×é¡£
½«Ò»¸ö»ò¶à¸ö±êÁ¿·â×°³ÉÒ»¸ö¶ÔÏó½øÐвÙ×÷¡£ÊÇÒ»ÖÖÁÙʱ¸´ºÏ¶ÔÏóÀàÐÍ¡£
 
 ¼Ç¼¿ÉÒÔÖ±½Ó¸³Öµ¡£RECORD1 :=RECORD2£»
 ¼Ç¼²»¿ÉÒÔÕûÌå±È½Ï. ......

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Íⲿ±íСÀý

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ºÅ