RANDOMINT

Accepts and returns an INTEGER value.

Accepts and returns an INTEGER value. RANDOMINT(n) returns one of the n integers from 0 through n – 1.

Typical pseudo-random generators accept a seed, which is set to generate a reproducible pseudo-random sequence. Vertica, however, distributes SQL processing over a cluster of nodes, where each node generates its own independent random sequence.

Results depending on RANDOM are not reproducible because the work might be divided differently across nodes. Therefore, Vertica automatically generates truly random seeds for each node each time a request is executed and does not provide a mechanism for forcing a specific seed.

Behavior type

Volatile

Syntax

RANDOMINT ( n )

Parameters

The value accepted is any positive integer (n) between the values 1 and 9,223,372,036,854,775,807.

For general information on integer data types, refer to the section, INTEGER.

Restrictions

If you provide a negative value, or if you exceed the maximum value, Vertica returns an error.

Examples

In the following example, the result is an INTEGER, which is >= 0 and < n, randomly chosen from the set {0,1,2,3,4}.

=> SELECT RANDOMINT(5);
RANDOMINT
----------
        3
(1 row)