Collections:
UUID_SHORT() - Short 64-Bit UUID Integer
How to generate a short 64-bit UUID (Universal Unique IDentifier) integer using the UUID_SHORT() function?
✍: FYIcenter.com
UUID_SHORT() is a MySQL built-in function that
returns a short 64-bit UUID (Universal Unique IDentifier) integer.
For example:
SELECT UUID_SHORT(), UUID_SHORT(); -- +--------------------+--------------------+ -- | UUID_SHORT() | UUID_SHORT() | -- +--------------------+--------------------+ -- | 100608899635216387 | 100608899635216388 | -- +--------------------+--------------------+ SELECT UUID_SHORT(), SLEEP(3), UUID_SHORT(); -- +--------------------+----------+--------------------+ -- | UUID_SHORT() | SLEEP(3) | UUID_SHORT() | -- +--------------------+----------+--------------------+ -- | 100608899635216389 | 0 | 100608899635216390 | -- +--------------------+----------+--------------------+
Reference information of the UUID_SHORT() function:
UUID_SHORT(): uuid Returns a 64-bit UUID integer based on system id and server startup time. Arguments, return value and availability: uuid: Return value. The generated UUID. Available since MySQL 5.7.
UUID_SHORT() function uses the following expression to generate the 64-bit UUID integer:
(server_id & 255) << 56 + (server_startup_time_in_seconds << 24) + incremented_variable++;
So the 64-bit UUID integer consists of 3 parts:
We can see these parts, if we convert the UUID integer into a Hexadecimal string:
SELECT HEX(UUID_SHORT()), HEX(UUID_SHORT()); -- +-------------------+-------------------+ -- | HEX(UUID_SHORT()) | HEX(UUID_SHORT()) | -- +-------------------+-------------------+ -- | 1656F42DC000008 | 1656F42DC000009 | -- +-------------------+-------------------+
⇒ UUID_TO_BIN() - Converting UUID to Binary
⇐ UUID() - Generating UUID String
2023-12-10, 1032🔥, 0💬
Popular Posts:
What Are the Differences between DATE and TIMESTAMP in Oracle? The main differences between DATE and...
How To Calculate DATETIME Value Differences Using the DATEDIFF() Function in SQL Server Transact-SQL...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
How To Convert Numeric Expression Data Types using the CAST() Function in SQL Server Transact-SQL? I...
How To Convert Numeric Expression Data Types using the CAST() Function in SQL Server Transact-SQL? I...