UUIDv7
MariaDB starting with 11.7
From MariaDB 11.7, it is possible to generate UUIDv4 and UUIDv7, in addition to UUIDv1.
Syntax
UUIDv4()
Contents
Description
Returns a Universally Unique Identifier (UUID) version 7. To generate a version 1 UUID, see the UUID function. To generate a version 4 UUID, see UUIDv4.
A UUID is designed as a number that is globally unique in space and time. Two calls to UUID()
are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.
UUIDv7() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.
A UUID is a 128-bit number represented by a utf8 string of five
hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
format:
Statements using the UUID() function are not safe for statement-based replication.
Examples
SELECT UUID(),UUIDv4(),UUIDv7(); +--------------------------------------+--------------------------------------+--------------------------------------+ | UUID() | UUIDv4() | UUIDv7() | +--------------------------------------+--------------------------------------+--------------------------------------+ | 46c81865-7999-11ef-98b2-f859713e4be4 | 9024d146-8dda-45ff-b4a5-75dcd842136c | 01921e7e-a679-7104-84b8-5dc479c44850 | +--------------------------------------+--------------------------------------+--------------------------------------+ CREATE TABLE t1 (a int primary key not null, u UUID DEFAULT UUIDv4(), unique key(u));
See Also
- UUID() v1
- UUIDv4()
- UUID_SHORT() - Return short (64 bit) Universal Unique Identifier
- SYS_GUID - UUID without the
-
character for Oracle compatibility - UUID data type
- MDEV-11339 (Support UUID v4 generation)
- MDEV-32637 (Implement native UUID7 function)