往数据库中批量插入一些数据(postgresql)
create or replace function mock_data() RETURNS
boolean AS
$BODY$
DECLARE i INTEGER;
BEGIN
i:=1;
--插入40条
FOR i IN 1..40 LOOP
-- 插入语句 拼接字符串
INSERT INTO device(a,b,c,d,e) VALUES(concat('aa',i),'bb',2,concat('cc',i),'3306','2021-04-09 16:20:50.841');
END LOOP;
return true;
end;
$BODY$
LANGUAGE plpgsql;
select * from mock_data() as t;