Questions tagged [uuid]

A UUID (Universally Unique IDentifier) is an identifier that is created with the intent of being, as the name suggests, universally unique.

A UUID (Universally Unique IDentifier) is an identifier that is created with the intent of being, as the name suggests, universally unique.

A UUID is a 16-octet (128-bit) number. In its canonical form, a UUID is represented by 32 hexadecimal digits, displayed in five groups separated by hyphens e.g.

5a0e8422-e29b-41d4-a716-416155440000

UUID is standardised by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE).

Wikipedia page for Universally Unique Identifier

See also:

3237 questions
83
votes
16 answers

What's your opinion on using UUIDs as database row identifiers, particularly in web apps?

I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a REST or Rails-like URL scheme for object instances, I'd then end up with URLs like this: http://example.com/user/783 And…
yukondude
  • 24,013
  • 13
  • 49
  • 58
81
votes
6 answers

How safe is it to remove the "-" in a randomly generated UUID?

I have this code: String uuid = UUID.randomUUID().toString().replace("-", ""); How safe is it to remove the "-" in the generated UUID? Would removing it defeat the purpose of it being globally unique and make the generated UUID prone to collisions?
quarks
  • 33,478
  • 73
  • 290
  • 513
81
votes
9 answers

How to generate a random UUID which is reproducible (with a seed) in Python

The uuid4() function of Python's module uuid generates a random UUID, and seems to generate a different one every time: In [1]: import uuid In [2]: uuid.uuid4() Out[2]: UUID('f6c9ad6c-eea0-4049-a7c5-56253bc3e9c0') In [3]: uuid.uuid4() Out[3]:…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
81
votes
2 answers

How to store uuid as number?

Based on the answer of question, UUID performance in MySQL, the person who answers suggest to store UUID as a number and not as a string. I'm not so sure how it can be done. Anyone could suggest me something? How my ruby code deal with that?
Chamnap
  • 4,666
  • 2
  • 34
  • 46
80
votes
9 answers

Store UUID v4 in MySQL

I'm generating UUIDs using PHP, per the function found here Now I want to store that in a MySQL database. What is the best/most efficient MySQL field format for storing UUID v4? I currently have varchar(256), but I'm pretty sure that's much larger…
Stephen R
  • 3,512
  • 1
  • 28
  • 45
80
votes
10 answers

Laravel UUID generation

I am trying to generate a UUID (not as primary key, just generate one) with the laravel-uuid package. The docs are pretty straightforward, so according to the readme file a UUID should be generated just by calling $uuid = Uuid::generate();, but it…
Skatch
  • 2,112
  • 2
  • 14
  • 32
79
votes
4 answers

Django migration with uuid field generates duplicated values

I have a uuid field (not a primary key). The generated migration is: from __future__ import unicode_literals from django.db import migrations, models import uuid class Migration(migrations.Migration): dependencies = [ .... ] …
blueFast
  • 41,341
  • 63
  • 198
  • 344
78
votes
4 answers

How do I represent a UUID in a protobuf message?

I want to attach a UUID to a field in my protobuf User message example. message User { // field containing id as UUID type required string email; optional string name; } I know that protobuf messages do not yet support the UUID type. I've…
Edward Maxedon
  • 1,151
  • 2
  • 11
  • 17
77
votes
9 answers

How to generate time based UUIDs?

I want to generate time-based universally unique identifier (UUID) in Java. The method java.util.UUID.randomUUID() generates a UUID Version 4 where 122 of the 128 bits are from a cryptographically-strong random number generator. How to generate a…
dogfish
  • 2,646
  • 4
  • 21
  • 37
76
votes
6 answers

UUID to unique integer id?

I was wondering what the easiest way to convert a UUID to a unique integer would be? I have tried using the hash code but people tell me that it is not going to always be unique if i use the hash code? So what is the easiest way? Is the hash code…
Alex Hope O'Connor
  • 9,354
  • 22
  • 69
  • 112
76
votes
8 answers

UUID('...') is not JSON serializable

I get this error when i try to pass the UUID attribute to url parameter. urlpatterns = [ url(r'^historia-clinica/(?P[W\d\-]+)/$', ClinicHistoryDetail.as_view(), name='...'), ] views.py class ClinicHistoryDetail(...): ... …
DJeanCar
  • 1,463
  • 1
  • 11
  • 13
75
votes
6 answers

How can I find the device uuid's of all connected devices through a command line script?

I am running automated tests on iOS devices. I want to not have to always have all devices connected. So I want to find all device id's and then only start the process of building, deploying, and running tests if that device is connected. So my…
SirRupertIII
  • 12,324
  • 20
  • 72
  • 121
73
votes
8 answers

How to preserve identifierForVendor in ios after uninstalling ios app on device?

I am developing an iOS app which calls web-service for login and at that time i send login credentials to web server along with vendor identifier (identifierForVendor),to identify device uniquely for those credentials.So user can have only one…
Harshavardhan
  • 1,266
  • 2
  • 14
  • 25
72
votes
7 answers

How to use UUID

I am trying to get unique IDs for my Django objects. In Django 1.8 they have the UUIDField. I am unsure how to use this field in order to generate unique IDs for each object in my model. Here is what I have for the UUIDField import uuid from…
Chad Crowe
  • 1,260
  • 1
  • 16
  • 21
69
votes
11 answers

How to get a unique computer identifier in Java (like disk ID or motherboard ID)?

I'd like to get an id unique to a computer with Java, on Windows, MacOS and, if possible, Linux. It could be a disk UUID, motherboard S/N... Runtime.getRuntime().exec can be used (it is not an applet). Ideas?
Gohu
  • 2,050
  • 2
  • 18
  • 17