PostgreSQL随机测试数据产生脚本

begin;
create or replace function random_string(integer)
returns text as
$body$
         select array_to_string(array(select                     substring('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' FROM (ceil(random()*62))::int FOR 1) FROM generate_series(1, $1)), '');
$body$ language sql volatile;  
create table person(id int,name text, age int);
insert into person select generate_series(1,1000000),random_string(floor(random()*20+10)),floor(random()*60+15);
drop function random_string(integer);
select pg_size_pretty(pg_relation_size('person'));
commit;
原文地址:https://www.cnblogs.com/bingo711x/p/8024812.html