Back to top
  Back to overview

Rand functions

These functions can be used when generating random data values.

Function Description
rand() Generates and returns a random floating point number
rand::bool() Generates and returns a random boolean
rand::enum() Randomly picks a value from the specified values
rand::float() Generates and returns a random floating point number
rand::guid() Generates and returns a random guid
rand::int() Generates and returns a random integer
rand::string() Generates and returns a random string
rand::time() Generates and returns a random datetime
rand::uuid() Generates and returns a random UUID

rand

The rand function generates a random float, between 0 and 1.

rand() -> number

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM rand();
0.7062321084863658

The following example shows this function being used in a SELECT statement with an ORDER BY clause:

SELECT * FROM [{ age: 33 }, { age: 45 }, { age: 39 }] ORDER BY rand();
[
	{
		age: 45
	},
	{
		age: 39
	},
	{
		age: 33
	}
]

rand::bool

The rand::bool function generates a random boolean value.

rand::bool() -> boolean

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM rand::bool();
true

rand::enum

The rand::enum function generates a random value, from a multitude of values.

rand::enum(value...) -> boolean

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM rand::enum('one', 'two', 3, 4.15385, 'five', true);
"five"

rand::float

The rand::float function generates a random float, between 0 and 1.

rand::float() -> float

If two numbers are provided, then the function generates a random float, between two numbers.

rand::float(number, number) -> float

The following examples show this function, and its output, when used in a select statement:

SELECT * FROM rand::float();
0.7812733136200293
SELECT * FROM rand::float(10, 15);
11.305355983514927

rand::guid

The rand::guid function generates a 20-character random guid.

rand::guid() -> string

If a number is provided, then the function generates a random guid, with a specific length.

rand::guid(number) -> string

The following examples show this function, and its output, when used in a select statement:

SELECT * FROM rand::guid();
"4uqmrmtjhtjeg77et0dl"
SELECT * FROM rand::guid(10);
"f3b6cjh0nt"

rand::int

The rand::int function generates a random int.

rand::int() -> int

If two numbers are provided, then the function generates a random int, between two numbers.

rand::int(number, number) -> int

The following examples show this function, and its output, when used in a select statement:

SELECT * FROM rand::int();
6841551695902514727
SELECT * FROM rand::int(10, 15);
13

rand::string

The rand::string function generates a random string, with 32 characters.

rand::string() -> string

The rand::string function generates a random string, with a specific length.

rand::string(number) -> string

If two numbers are provided, then the function generates a random string, with a length between two numbers.

rand::string(number, number) -> string

The following examples show this function, and its output, when used in a select statement:

SELECT * FROM rand::string();
"N8Q86mklN6U7kv0A2XCRh5UlpQMSvdoT"
SELECT * FROM rand::string(15);
"aSCtrfJj4pSJ7Xq"
SELECT * FROM rand::string(10, 15);
"rEUWFUMcx0YH"

rand::time

The rand::time function generates a random datetime.

rand::time() -> datetime

The rand::time function generates a random datetime, between two unix timestamps.

rand::time(number, number) -> datetime

The following examples show this function, and its output, when used in a select statement:

SELECT * FROM rand::time();
"2026-09-07T04:27:53Z"
SELECT * FROM rand::time(198371, 1223138713);
"1991-01-13T23:27:17Z"

rand::uuid

The rand::uuid function generates a random UUID.

rand::uuid() -> uuid

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM rand::uuid();
"e20b2836-e689-4643-998d-b17a16800323"