Answer the question
In order to leave comments, you need to log in
How to shuffle characters in a string?
How do I move letters in the end string of a password?
SELECT string_agg(concat(
substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(random() * 26)::integer, 1),
substring('abcdefghijklmnopqrstuvwxyz', ceil(random() * 26)::integer, 1),
substring('0123456789', ceil(random() * 10)::integer, 1),
substring('!#$%&()*+,-./:;<=>[email protected][]^', ceil(random() * 23)::integer, 1)
), '')
FROM generate_series(1,8);
Answer the question
In order to leave comments, you need to log in
Well mix it up...
SELECT string_agg(concat(substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(random() * 26)::integer, 1),
substring('abcdefghijklmnopqrstuvwxyz', ceil(random() * 26)::integer, 1),
substring('0123456789', ceil(random() * 10)::integer, 1),
substring('!#$%&()*+,-./:;<=>[email protected][]^', ceil(random() * 23)::integer, 1)
),
'' ORDER BY RANDOM()
)
FROM generate_series(1,8);
SELECT string_agg(unnest, '') FROM(
select * FROM (select unnest(string_to_array(string_agg(concat(
substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(random() * 26)::integer, 1),
substring('abcdefghijklmnopqrstuvwxyz', ceil(random() * 26)::integer, 1),
substring('0123456789', ceil(random() * 10)::integer, 1),
substring('!#$%&()*+,-./:;<=>[email protected][]^', ceil(random() * 23)::integer, 1)
), ''), NULL)) FROM generate_series(1,8)) x ORDER BY RANDOM()) as random_chars
Your perseverance is impressive:
select string_agg(substring, '') from (
SELECT
substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(random() * 26)::integer, 1)
FROM generate_series(1,12) -- 12 capital letters
union
SELECT
substring('abcdefghijklmnopqrstuvwxyz', ceil(random() * 26)::integer, 1)
FROM generate_series(1,12) -- 12 low case letters
union
SELECT
substring('0123456789', ceil(random() * 10)::integer, 1)
FROM generate_series(1,6) -- 6 digits
union
SELECT
substring('!#$%&()*+,-./:;<=>[email protected][]^', ceil(random() * 23)::integer, 1)
FROM generate_series(1,2) -- 2 other chars
) seria;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question