Name

UUID()

Synopsis

UUID()

This function returns a Universal Unique Identifier (UUID), a 128-bit number composed of five hexadecimal numbers. This number is intended to be unique per invocation and is based on values that are both temporal and spatial. There are no arguments for the function. It’s available as of version 4.1.2 of MySQL. Here is an example:

SELECT UUID( );

+----------------------------------------+
| UUID( )                                |
+----------------------------------------+
| '8bde367a-caeb-0933-1031-7730g3321c32' |
+----------------------------------------+

The first three hexadecimal sets of numbers are based on the date and time of the execution of the statement. The fourth set is based on time regardless of daylight saving time. The last set is a unique number, an IEEE 802 node number related to the computer generating the number. For instance, for some operating systems it could be the network card’s Media Access Control (MAC) address.

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.