Generate Random or Sequential GUIDs
Generate random or sequential GUIDs in various formats. Choose between braces or no braces, hyphens or no hyphens upper case or lower case.
About The Tool
Generate up to 500 globally unique identifiers (GUIDs) in several different variant formats. Select the check box options to include braces, hyphens, upper or lower case and random or sequential.
This tool creates Variant 2, Version 4 UUIDs in adherence to the RFC4122 specification. They have a very high degree of certainty to never have been generated before. They are suitable for use as a persistent identifier within a distributed system.
Globally Unique Identifiers
The term GUID and UUID are interchangeable with each other. They stand for globally unique identifier and universally unique identifier respectively. A GUID is a 128-bit integer 16 bytes in length whose value follows a specific structure. When using a standard method to create GUIDs, they will be unique. It is possible to generate a duplicate however the chances are infinitesimal. Thus there is no need to rely on a centralized authority to coordinate uniqueness between UUID generators. The RFC specification outlines several methods for generating new GUIDs differentiated by version numbers.
Version 1
Uses a combination of date-time clock sequence and usually MAC address to generate sequences of GUIDs. It is possible to extract the MAC address and identify the source generation machine.
Version 2
This version is not common and most implementations skip it. It also uses a combination of date-time and MAC address but also has a local domain number. The result is a smaller amount of entropy and the risk of collision is higher. In addition, the local domain component borrows bits from the date-time component used in version 1. The end result is a new unique GUID is able to be generated roughly every seven minutes per UUID generator.
Version 3 and 5
Both versions use a namespace for UUID creation. The namespace can be a URL, fully qualified domain name, object identifier or and other sequence of bytes. The input name is concatenated with the namespace and then hashed with MD5 (version 3) or SHA1 (version 5). The same named identifier and namespace inputs will yield the same GUID.
Version 4
Random GUID generators use version 4, this online tool is no different. This version uses random numbers to create a stream of 122-bits merged with 4 indicator bits for the version and variant. This is the most common implementation used to create a UUID. When the same randomly generated value occurring twice is known as a collision.
Collisions
The number of unique values possible when generating random UUIDs is so vast that every grain of sand on every planet in every solar system within the Milky Way could be assigned a UUID and they would all still have unique identifiers.
Database Keys
Arguably the most common uses for GUIDs are unique identifiers within a database. Using this method, a database entity can have it's own unique identifier across databases. As micro-services become more popular, having multiple databases with references to rows in others is becoming more common.
Distributed Data
It is common to see a database schema use 32-bit or 64-bit incremented integers as database keys. Everything works fine until the data in two separate databases needs to be merged into a data warehouse. Both sources will likely have the same key for different data and the keys will need to be reassigned in the merge. Things quickly get complicated when other entities have foreign key references to the keys being reassigned.
Pitfalls of Random GUIDs as Database Keys
GUIDs are poor choices for clustered index keys because the data is ordered on disk by the value of the key. Random values mean the data is stored randomly making reading pages of data very inefficient. Queries become much slower and CPU and disk IO go up.
How to Structure Database Tables
Each table still uses 64-bit sequential integers for their clustered index keys. Any references within the same closely related set of tables can still use these integers as foreign keys. Each table will also have a randomly generated GUID as an external identifier that has a non-clustered index. Treat the integer key as an internal identifier for that database. Internal identifiers should never be exposed in any data queried from the database, instead use the external identifier.