-- 生成范围内的随机数据, 如下图为 10000条随机数据
select
round(cast(random()+90 as numeric),2)||'%' as d /*取99%~100%的随机数*/
,floor(random()*10000000000)
,(array['男','女','其他'])[floor(random()*3)::int+1] /*在性别数组中随机取性别*/
,(array['小四','小花','小凡'])[floor(random()*3)::int+1] /*在名字数组中随机取名字*/
,floor(random()*(10000000000-13899999999)+13899999999) /*生成相对正确的手机号*/
from generate_series(1,10000);
-- 创建当前仅连接可用的临时表
create temporary table student as
select * from
(values
(1, '小明', 20),
(2, '小红', 20),
(3, '小亮', 22))
tab(id, name, age);
select * from student;