GENERATE_UUID scalar function

The GENERATE_UUID function returns the formatted string representation of a Universally Unique Identifier (UUID) using the version 4 algorithm.

Read syntax diagramSkip visual syntax diagramGENERATE_UUID()

The schema is SYSIBM.

The function is defined as non-deterministic.

Results

The result of the function is a CHAR(36) value formatted like xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx. Characters in the string are in upper case. The CCSID of the result is the default SBCS CCSID at the current server.

The result cannot be null.

Example

The following example shows the command syntax for generating a CHAR(36) string UUID value:
value.VALUES GENERATE_UUID()
The following example shows the format of a generated CHAR(36) UUID:
D83D6360-1818-41EB-9804-B622A1FE5492