©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The UUID SQL Function in MySQL and MariaDB - Universal Unique Identifier

UUIDSyntax:UUID()
Return value:CHAR
Function type:Miscellaneous function
Function Description

The UUID() function returns a Universally Unique Identifier (UUID).

A UUID is designed as a spatially and temporally unique number worldwide. Two calls to UUID() result in two different values, even if those calls are made on two different servers.

A UUID is a 128-bit number represented by a string of five hexadecimal digits in the format aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:

The first three numbers are generated from a timestamp.

The fourth number preserves the temporal uniqueness in case the timestamp value loses continuity, for example due to daylight saving time.

The fifth number is an IEEE 802 node number, for spatial uniqueness. If a node number is not available, it is replaced with a random number. In this case, spatial uniqueness cannot be guaranteed.

SQL Examples for the UUID function

 1
 2
 3
 4

SELECT uuid();
SELECT uuid();

uuid()
varchar(36) BINARY
decb92d4-d5bd-11ed-9a48-0800275588ea
uuid()
varchar(36) BINARY
decbc7b8-d5bd-11ed-9a48-0800275588ea
The examples were created with the MyWAY SQL manager: Download

How to use the UUID() function in MySQL and MariaDB databases

In MySQL and MariaDB the UUID() function is used to generate a new UUID (Universally Unique Identifier). The function can be used directly in SQL statements or within SQL queries, requires no arguments, and returns a randomly generated UUID value as a string of hexadecimal digits in the format "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" which is unique in the context of the server or session.

UUIDs are used as unique identifiers in database systems, for example as primary keys or for other identification purposes. When working with distributed systems or data replication and data synchronization, generating unique UUIDs can help avoid conflicts and ensure data integrity across multiple nodes or databases. Further, the UUID() function can be used to generate test data with unique identifiers during application development or testing.
UTC_DATEUTC_TIMEUTC_TIMESTAMPUUIDUUID_SHORTUUID_TO_BINVAR_POP

Further MySQL und MariaDB SQL Miscellaneous functions

BIN_TO_UUIDBIN_TO_UUID(Binary string [, Swap])
More about BIN_TO_UUID Function

GET_LOCKGET_LOCK()

INET6_ATONINET6_ATON(String)
More about INET6_ATON Function

INET6_NTOAINET6_NTOA(Binary string)
More about INET6_NTOA Function

INET_ATONINET_ATON(String)
More about INET_ATON Function

INET_NTOAINET_NTOA(Value)
More about INET_NTOA Function

IS_FREE_LOCKIS_FREE_LOCK()

IS_IPV4IS_IPV4(String)
More about IS_IPV4 Function

IS_IPV4_COMPATIS_IPV4_COMPAT(String)

IS_IPV4_MAPPEDIS_IPV4_MAPPED(String)

IS_IPV6IS_IPV6(String)
More about IS_IPV6 Function

IS_USED_LOCKIS_USED_LOCK()

IS_UUIDIS_UUID(String)
More about IS_UUID Function

MASTER_GTID_WAITMASTER_GTID_WAIT()

MASTER_POS_WAITMASTER_POS_WAIT()

NAME_CONSTNAME_CONST(Name, Value)
More about NAME_CONST Function

RELEASE_ALL_LOCKSRELEASE_ALL_LOCKS()

RELEASE_LOCKRELEASE_LOCK()

SYS_GUIDSYS_GUID()
More about SYS_GUID Function

UUID_SHORTUUID_SHORT()
More about UUID_SHORT Function

UUID_TO_BINUUID_TO_BIN(String [, Swap])
More about UUID_TO_BIN Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the UUID SQL function: mysql.com and mariadb.com
Updated: 2023-09-17ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer