create function f_random_str(length INTEGER) returns character varying
LANGUAGE plpgsql
AS $$
DECLARE
result varchar(50);
BEGIN
SELECT array_to_string(ARRAY(SELECT chr((65 + round(random() * 25)) :: integer)
FROM generate_series(1,length)), '') INTO result;
return result;
END
$$;
网友评论