Skip to content

DETERMINISTIC

CREATE FUNCTION deterministic_example(input INT)
RETURNS INT
DETERMINISTIC
BEGIN
RETURN input * 2;
END;
Query OK, 0 rows affected (0.01 sec)

In the provided example, a function named deterministic_example is created. It accepts an integer input, which it then multiplies by 2. The DETERMINISTIC statement means that MySQL can expect that for the same input, the function will always return the same output. The function is DETERMINISTIC since for any given input, the output (input * 2) will always be the same.