【发布时间】:2013-04-29 22:22:18
【问题描述】:
在 PostgreSQL 中是否有一些方法可以像在 Oracle 中一样使用批量收集来生成语句?
Oracle 中的示例:
create or replace procedure prc_tst_bulk_test is
type typ_person is table of tb_person%rowtype;
v_tb_person typ_person;
begin
select *
bulk collect into v_tb_person
from tb_person;
-- make a selection in v_tb_person, for instance
select name, count(*) from v_tb_person where age > 50
union
select name, count(*) from v_tb_person where gender = 1
end;
谢谢
【问题讨论】:
-
“批量收集到”有什么作用?我根本不熟悉那种语法。
-
看起来是性能优化提示。 dba-oracle.com/t_oracle_bulk_collect.htm 。它似乎将行块提取到临时内存表中。
-
您可能还想查看cursors 以获得类似于
bulkcopy的内容。
标签: postgresql plpgsql