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的建库工
且DBCA,这是一个图形界面工且,使用起来方便且很容易理解,因为它的界面友好、美观,而且提示也比较齐全。在Windows系统中,这个工具可以在Oracle程序组中打开(”开始”—“程序”—“ Oracle OraDb10g_home1”&mdash ......
一,Oracle数据库用户简介
在Oracle数据库中任何对象都属于一个特定用户,或者说一个用户与同名的模式相关联。
要连接到Oracle数据库需要一个用户帐户,根据需要授予的操作权限。
1,默认数据库用户模式:
Sys:数据库字典(存储被管理对象所有信息)和视图存储在该模式中。系统级用户。 ......
Oracle Database 10g 提供了一个显著改进的工具:自动工作负载信息库 (AWR:Automatic Workload Repository)。Oracle 建议用户用这个取代 Statspack。AWR 实质上是一个 Oracle 的内置工具,它采集与性能相关的统计数据,并从那些统计数据中导出性能量度,以跟踪潜在的问题。与 Statspack 不同,快照由一个称为 MMON 的新的后 ......
一、Enterprise Manager 10g
默认情况下,安装Oracle时,会安装EM。它是位于数据库服务器上的HTTP服务器。
(1)启动EM
要确保OracleDBConsole<SID>服务已经启动。
启动服务:emctl start dbconsole
关闭服务:emctl stop dbconsole
访问EM:http://服务器名称:端口号/em
端口号可在$ORACLE_HOME/install/pro ......
原创于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 ......