随机范围
来自 PostgreSQL 维基
跳转到导航跳转到搜索作者:Scott Bailey 'Artacus'
CREATE OR REPLACE FUNCTION random(numeric, numeric)
RETURNS numeric AS
$$
SELECT ($1 + ($2 - $1) * random())::numeric;
$$ LANGUAGE 'sql' VOLATILE;
用法
SELECT random(1,10)::int, random(1,10);
random random
--------- ----------------
5 3.20581795740873