create temp table test_data ( id int not null, data text not null ); with short as (select array_agg(iso) c from countries), series as (select i from generate_series(1, 500) as i) insert into test_data (id, data) select series.i, substr(md5(random()::text), 0, floor(random() * 25 + 2)::int) || '.' || (short.c)[floor(random() * 239+1)] from series, short;