I need to put some random values into database, but I don't want to end up with completely randomized text (like 7hfg43d3). Instead I would like to randomly pick one of values supplied by myself.
Nice idea. I suggest two minor simplifications:
OK, theoretically, the lower border could be 0 precisely, as hinted in the comment by @korda, since
However, I have never seen that happen. Run a couple of million tests:
To be perfectly safe, though, you can use Postgres custom array subscripts and still avoid the extra addition:
Or better yet, use
I came up with idea to use Arrays to accomplish this: