Skip to content

SETSEED

  • double precision: This parameter is used to set the seed for the next `random()` or `random(n)` function call. The value should be between -1.0 and 1.0, inclusive. This seed value specifies a new starting point for the sequence of random numbers generated by the `random()` function.
SELECT SETSEED(0.5);
SELECT RANDOM();
setseed
---------
(1 row)
random
--------
0.287299
(1 row)

SETSEED sets the seed for the next RANDOM command. The argument to SETSEED is a double precision number. The command SETSEED(0.5); sets the seed to 0.5. In the output, the setseed operation returns 1 row signifying seed was successfully set. In the next command RANDOM(), it returns a pseudorandom number based on the seed value.