Will RANDOMSTRING() ever repeat?

Hey @wz2b

The random string function can conceivably return a duplicate value. This can be check for with triggers. The generated random string can be stored to to a variable, then you can check to see if a record exists with that ID, if it does, generate a new random ID.


Having said that, a 17 character case sensitive alpha-numeric has a potential 2.95 X 10^30 unique options. This is ~30 order of magnitude more than the count of atoms in the known universe. Unfortunately generating truly random strings isn’t possible. I reached out to our developers to understand what we are using for the seed value for the random string generator. I will update this thread when I have an answer.

As a little more context - There is a feature in the works right now where records could be created with a random id without the need of an expression, the RANDOM_STRING() function, etc. This will respect GUID principals and insure no duplicates are generated. The RANDOM_STRING() function has a place, but shouldn’t be needed to do something as universal as creating records.

Pete

2 Likes