Oracle数据库游标的类型(二)
PDATE, DELETE语句的执行,也就是用FORALL语句来替代循环语句。
2.加速SELECT,用BULK COLLECT INTO 来替代INTO。
create table student_tmp as select sno,sname from student where 0=1; --删除主键约束 alter table student drop constraint SYS_C0040802; --执行两遍插入 insert into student select * from student where sno=50; declare cursor cur_std(stdid student.sno%type) is select sno,sname from student where sno=stdid; type student_table_type is table of cur_std%rowtype index by pls_integer; student_table student_table_type; begin open cur_std(50); fetch cur_std bulk collect into student_table; close cur_std; for i in 1..student_table.count loop dbms_output.put_line(student_table(i).sno || ' ' || student_table(i).sname); end loop; forall i in student_table.first..student_table.last insert into student_tmp values(student_table(i).sno, student_table(i).sname); commit; end; --清理实验环境 drop table student purge; drop package pkg_test01;