postgresql函数存储过程实现数据批量插入
在实际的项目开发过程中,我们经常会遇到批量的造测试数据,如果手动的一条一条造,那么势必会非常浪费时间,而且很容易出错,使用函数存储过程将会成倍的提高工作效率。
create or replace function creatData2() returns boolean AS $BODY$ declare ii integer; begin II:=1; FOR ii IN 1000..2000 LOOP INSERT INTO "t_member_score_item2"("member_score_item_id", "member_code", "score_type", "score", "sys_no", "remark", "insert_time", "insert_oper", "update_time", "update_oper") VALUES (ii, '01862204522573', '06', '100.000000', '04', NULL, now(), 'mv', now(), 'mv'); end loop; return true; end; $BODY$ LANGUAGE plpgsql; select * from creatData2() as tab; select * from t_member_score_item2