Universal Unique Identifier (UUID)

Universal Unique Identifier (UUID) ou Identificador Universal Único
UUID

If it were an advertisement for a bank or credit card, I would say: there are moments when you need to be exclusive

There will be times when the primary key may not be enough to guarantee uniqueness and/or exclusivity for a row in the table, or even for a specific resource.

PHP developers are already quite familiar with UUID. Many use UUID for session control.

Well, it’s possible to generate UUIDs directly from the database, regardless of the programming language you intend to use. This is guaranteed through the UUID() function.

In general terms, the UUID() function generates a 32-character alphanumeric sequence, but as this sequence is divided into 4 blocks, there are also 4 dividers, represented by the character “-”. Therefore, to store a UUID, we need 36 bytes/characters.

A given server will not emit two identical UUID results for a long period of time.

Example:

Editarmysql> select UUID();
+--------------------------------------+
| UUID() |
+--------------------------------------+
| faa91148-341c-11e2-bb8e-1293aba126db |
+--------------------------------------+
1 row in set (0.00 sec)

or

mysql> INSERT INTO table SET id=UUID(), name = 'xpto'…..

Schedule a meeting here

Visit our Blog

Learn more about databases

Learn about monitoring with advanced tools

UUID

Have questions about our services? Visit our FAQ

Want to see how we’ve helped other companies? Check out what our clients say in these testimonials!

Discover the History of HTI Tecnologia

Compartilhar: