循环添加数据到表:
DO $$
DECLARE
i INTEGER := 1;
BEGIN
WHILE i < 10000000 LOOP
insert into "beego-api"."User" (name, phone) values (concat(‘name‘, i, NULL, NULL), concat(‘phone‘, i));
i = i + 1;
END LOOP;
END $$;
批量插入更新:
insert into 表1(字段1,字段2) values () on conflict (字段1) do update set 字段1=excluded.字段1