You can generate true random strings with this expression:
array_to_string(array_foreach(generate_series(1,10),replace(@element,@element,char(rand(97,122)))),'')
Note that this will not generate random words! Just random characters concatenated.
How it works: generate_series(1,10)
creates an array of length 10. This will be the length of your final random string. Change the 10 to whatever string length you wish to generate. Now we loop through this array using array_foreach()
and replace every element with a random character. We get this random character using char()
function: char(97,122)
will create a random character from the unicode table with codes between 97 and 122, which is the latin lowercase alphabet. Lookup here https://en.wikipedia.org/wiki/List_of_Unicode_characters. Change these numbers to whatever characters you wish to generate. As last step, we concatenate the array of random characters to a string using nothing as separator (''
).
If you also want a random string length, you can modifiy the expression a little and use rand(min,max)
as maximum in generate_series()
:
array_to_string(array_foreach(generate_series(1,rand(1,22)),replace(@element,@element,char(rand(97,122)))),'')
Example result: