Menu

MariaDB UUID Data Type

MariaDB’s UUID data type stores 128-bit UUID values. It is available from MariaDB 10.7. Values are returned in the standard hyphenated UUID string format, while the type stores the value in an index-friendly representation.

Create a UUID column

Use UUID like other column types:

CREATE TABLE events (
    event_id UUID PRIMARY KEY,
    event_name VARCHAR(80) NOT NULL
);

The type does not generate values or enforce uniqueness on its own; this example uses a PRIMARY KEY to reject duplicate identifiers. MariaDB’s UUID() function generates UUIDv1 values:

INSERT INTO events (event_id, event_name)
VALUES (UUID(), 'account_created');

MariaDB 11.7 and later also provide UUID_v4() and UUID_v7().

Accepted input formats

The type accepts UUID strings, hexadecimal strings, and binary values. UUID string input may use the standard hyphenated format or omit hyphens; MariaDB rejects braces around the UUID. SYS_GUID() output without hyphens can be inserted into a UUID column. UUID_SHORT() returns a 64-bit integer and is not a full-length UUID.

When retrieved, the value is displayed in the standard 36-character format, for example:

123e4567-e89b-12d3-a456-426655440000

UUID storage and ordering

MariaDB stores UUID values in an order designed to make UUIDv1 index-friendly. Starting with MariaDB 10.10.6 and 10.11.5, UUID versions 6 and later are stored without the earlier byte-swapping behavior; this includes UUIDv7. Check the server version when relying on UUID ordering across upgrades.

For function behavior, see the UUID(), UUID_v4(), and UUID_v7() references. See MariaDB’s official UUID data type documentation for the full casting and storage rules.