PG数据库创建并执行存储过程批量插入数据

时间:2022-06-09 09:53:58

记录一下PG数据库创建并执行存储过程批量插入数据的SQL:

create or replace function addId() returns
boolean AS
$BODY$
declare ii integer;
begin
ii := 1;
FOR ii IN 1..1000000 LOOP
INSERT INTO test01 (id) VALUES (ii);
end LOOP;
return true;
end;
$BODY$
LANGUAGE plpgsql; select * from addId();