Universally Unique Identifier (UUID) is a 128-bit label used for information in computer systems. This has standards for generating the identifier for uniqueness and independent code generation. Its existence since year 1980 with Appollo computer used in Network Computer System and later adapted by Open Software Foundation in Distributed Computing Environment.
There are other standards organizations has registered and make the identifier specification such as RFC, ITU and IETF.
UUID stands for Universal Unique Identifier defined by RFC 4122
Format:
Field | NDR Data Type | Octet # | Note |
---|---|---|---|
time_low | unsigned long | 0-3 | The low field of the timestamp. |
time_mid | unsigned short | 4-5 | The middle field of the timestamp. |
time_hi_and_version | unsigned short | 6-7 | The high field of the timestamp multiplexed with the version number. |
clock_seq_hi_and_reserved | unsigned small | 8 | The high field of the clock sequence multiplexed with the variant. |
clock_seq_low | unsigned small | 9 | The low field of the clock sequence. |
node | character | 10-15 | The spatially unique node identifier. |
how to use?
we can generate UUID in any standard programming language or general-purpose application software.
we are going to look into the following:
Database system:
Database – function – data type
- Oracle – sys_guid() – RAW(16)
- SQL Server – NEWID() – uniqueidentifier
- PostgreSQL – gen_random_uuid() – UUID
- MySQL – UUID() – BINARY(16)
Programming language:
Python:
The uuid module provides immutable UUID objects (the UUID class) and the following functions
uuid1()
, uuid3()
, uuid4()
, uuid5()
are for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122.
note: version 1 may have the privacy issue. please use these functions with full understanding.
acronyms:
- RFC – Request for Comment
- ITU – International Telecommunication Union
- IETF – Internet Engineering Task Force
Ref: