循环插入

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 
$$
;

 

posted on 2023-06-14 22:24  张释文  阅读(265)  评论(0编辑  收藏  举报