Menu

MariaDB UUID_v7() Function

UUID_v7() generates a version 7 UUID whose value is sortable by creation time. The function is available in MariaDB 11.7 and later and takes no arguments.

Syntax

UUID_v7()

The function returns a 128-bit UUID as a 36-character UTF-8 string in the standard hyphenated format:

SELECT UUID_v7();

Example result:

+--------------------------------------+
| UUID_v7()                            |
+--------------------------------------+
| 01921e85-f198-7490-9b89-7dd0d468543b |
+--------------------------------------+

UUIDv7 embeds time information, so values sort by creation time. The timestamp can reveal an approximate creation time, so do not use UUIDv7 as a secret token. Statements using UUID_v7() are not safe for statement-based replication.

You can store the result in MariaDB’s UUID data type, available from MariaDB 10.7. For other generation methods, see UUID_v4() and the version 1 UUID() function.

See MariaDB’s official UUID_v7() documentation.