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

记录一下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();
posted @ 2019-11-27 16:29  还可入梦  阅读(3615)  评论(0编辑  收藏  举报