循环插入
DO $$ DECLARE tmp RECORD; BEGIN FOR tmp IN select distinct id from test LOOP INSERT INTO test1 (id,role_code,privilege_code,space_id) VALUES (FLOOR(random() * 2147483646),'COMMON_USER','test',tmp.space_id); END LOOP; END $$ ;
标签:tmp,code,postgresql,查询,插入,test,END,id From: https://www.cnblogs.com/zhangshiwen/p/17481538.html