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表空间操作详解
1
2
3作者: 来源: 更新日期:2006-01-04
5
6
7建立表空间
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
命令行维护Oracle AWR
有时候由于种种原因,只能使用命令行来维护Oracle10g。当然我们依然可以使用statspack,但由于statspack功能不如AWR,而
且如果使用两种性能诊断工具也是一种浪费。因此手动维护AWR还是有必要的,下面列出一些常用的AWR命令,以备后查。
1、修改AWR的触发频率
......
Oracle系列:记录(Record)
一,什么是记录(Record)?
由单行多列的标量构成的复合结构。可以看做是一种用户自定义数据类型。组成类似于多维数组。
将一个或多个标量封装成一个对象进行操作。是一种临时复合对象类型。
记录可以直接赋值。RECORD1 :=RECORD2;
记录不可以整体比较. ......
FORALL语句的一个关键性改进,它可大大简化代码,并且对于那些要在PL/SQL程序中更新很多行数据的程序来说,它可显著提高其性能。
1:
用FORALL来增强DML的处理能力
Oracle为Oracle8i中的PL/SQL引入了两个新的数据操纵语言(DML)语句:BULK COLLECT和FORALL。这两个语句在PL/SQL内部进行一种数组处理
;BULK COLLE ......
原创于2007年04月12日,2009年10月15日迁移至此。
windows xp,数据库oracle 10.2.0。1
没有备份,基本上是默认安装,好像还不是归档模式
症状:sqlplus只有sysdba用户能进去,其他用户进去一概报:ora-01033:oracle正在初始化或关闭
而且sysdba用户进去之后能执行select sysdate from dual,但是执行select use ......