MeridianMERIDIAN

UUID

representation.identifier.uuid

Universally Unique Identifier (RFC 9562, which obsoletes RFC 4122). Versions include v1 (timestamp-based), v4 (random), v5 (name-based), and v6, v7 and v8 (time-ordered and custom layouts). Text form: 8-4-4-4-12 hex groups with hyphens; the hex digits may be upper, lower or mixed case, and lowercase is preferred.

Shape

Pattern
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
ValueLengthShape
550e8400-e29b-41d4-a716-44665544000036matches
6ba7b810-9dad-11d1-80b4-00c04fd430c836matches
f47ac10b-58cc-4372-a567-0e02b2c3d47936matches
550e8400-e29b-41d4-a716-4466554400035rejected: one character short

Told apart

1 of the 3 other identifier types accept every one of these samples on shape alone.

Background

Origin

UUIDs were originally used in the Apollo Network Computing System (NCS), later in the Open Software Foundation's Distributed Computing Environment (DCE), and then in Microsoft Windows platforms.[1] Apollo Computer's Network Computing System, which used UUIDs, was launched in 1987.[2] Microsoft Windows platforms adopted the NCS, and later the DCE, design as Globally Unique Identifiers (GUIDs) in the early nineties.[2] ISO/IEC documented the DCE design in 1996, in ISO/IEC 11578:1996.[2]

RFC 4122, A Universally Unique IDentifier (UUID) URN Namespace, was published in July 2005.[3] RFC 9562 says an ITU-T Recommendation and an ISO/IEC Standard are derived from RFC 4122.[1] RFC 9562 says the ITU-T and ISO/IEC specifications and the RFC have been aligned and are fully technically compatible.[1]

RFC 9562 gives as one of the main reasons for using UUIDs that no centralised authority is required to administer them.[1] RFC 9562 says UUIDs have gained popularity as database keys because the auto-increment schemes often used by databases do not work well in distributed applications.[1] RFC 9562 says UUID versions that are not time ordered, such as UUIDv4, have poor database-index locality.[1] UUIDv7 places a Unix timestamp in milliseconds in the most significant 48 bits of the UUID.[1] RFC 9562 says implementations should use UUIDv7 instead of UUIDv1 and UUIDv6 if possible.[1]

Use

RFC 9562 says UUIDs comprise the core identifier infrastructure for many operating systems such as Microsoft Windows and applications such as the Mozilla web browser.[1] A UUID is 128 bits long.[1] RFC 9562 calls the standard text form of a UUID the hex-and-dash string format, groups of hexadecimal characters separated by single hyphens.[1] PostgreSQL writes a UUID as a group of 8 hexadecimal digits, then three groups of 4 digits, then a group of 12 digits, for 32 digits in total.[4]

Microsoft's .NET Guid.ToString method can write a GUID as 32 digits with no hyphens, with hyphens, with hyphens enclosed in braces, or with hyphens enclosed in parentheses.[5] By default, .NET's Guid.ToString writes lowercase hexadecimal digits in groups of 8, 4, 4, 4 and 12, separated by hyphens.[5] Python's uuid module accepts a string of hex digits with or without curly braces, hyphens and a URN prefix.[6] PostgreSQL accepts UUID input surrounded by braces, or with some or all hyphens omitted.[4] PostgreSQL always outputs a UUID in the standard form.[4] When a column mixes these spellings, normalise every value to the bare hyphenated form before you compare or join on it. (Meridian's view) A 32-character hexadecimal string with no hyphens may be a UUID with its hyphens stripped, or something else entirely, so find out where it came from before you cast it. (Meridian's view)

In the text form of a UUID, the version is the hex digit after the second hyphen.[2] DuckDB retrieves the version of a UUID value with the uuid_extract_version function.[7] DuckDB retrieves the timestamp from a UUIDv7 value with the uuid_extract_timestamp function.[7] RFC 9562 advises treating UUIDs as opaquely as possible and avoiding parsing them unless absolutely necessary.[1] Look at the digit after the second hyphen to learn which version a column holds, but resist building logic that depends on what is inside the identifier. (Meridian's view)

RFC 9562 says UUIDs should be stored within database applications as the underlying 128-bit binary value where feasible.[1] RFC 9562 notes that storing UUIDs as text requires 288 bits to represent a 128-bit value.[1] DuckDB's UUID type uses 128 bits and is represented internally as HUGEINT values.[7] DuckDB prints a UUID with lowercase hexadecimal characters separated by dashes, using 36 characters in total.[7] SQL Server's uniqueidentifier data type is a 16-byte GUID.[8] SQL Server does not order uniqueidentifier values by comparing the bit patterns of the two values.[8] RFC 9562 notes that Microsoft's Component Object Model (COM) GUIDs use little-endian byte order when saved in binary, while RFC 9562 sequences all fields in big-endian format.[1] Do not expect a set of UUIDs to sort the same way in every database, and when a binary GUID from a Microsoft system turns into a different string than its source shows, suspect byte order before you suspect the data. (Meridian's view)

RFC 9562 says implementations should not assume that UUIDs are hard to guess.[1] Python's documentation notes that uuid1() may compromise privacy because it creates a UUID containing the computer's network address.[6] RFC 9562 cautions database schema designers against using name-based UUIDs as primary keys in tables.[1] PostgreSQL provides native support for generating UUIDs using the UUIDv4 and UUIDv7 algorithms.[4] DuckDB supports generating UUIDv4 and UUIDv7 identifiers.[7] Python's uuid module added UUID versions 6, 7 and 8 in version 3.14.[6]

Where you'll meet it

GOV.UK's Publishing API uses a UUID value, content_id, to identify distinct pieces of content on GOV.UK.[9] On GOV.UK, the same content_id is used for content that is available in multiple translations.[9]

Detection notes

Moved from technology.cryptographic.uuid in v0.5.1. UUID is a universal identifier used in database design far beyond technology contexts. DuckDB UUID type accepts standard 8-4-4-4-12 format. Also accepts without hyphens via UPPER() or normalization.

Use it

CLI · DuckDB
$ finetype infer -i "550e8400-e29b-41d4-a716-446655440000" --mode column
→ representation.identifier.uuid

SELECT ft_infer('550e8400-e29b-41d4-a716-446655440000');
-- → 'representation.identifier.uuid'
Cast expression
CAST({col} AS UUID)

Schema

https://meridian.online/schemas/representation.identifier.uuid · Frictionless type string · uuid

finetype taxonomy representation.identifier.uuid -o json-schema

Aliases

guid

Type Registry