Is it possible to create a duplicate UUID in laravel?

884 Views Asked by At

I am making UUIDs like this:

Uuid::uuid4();

and save in a database as track id.

Is it possible to create a duplicate UUID?

1

There are 1 best solutions below

0
brice On

If you are not using a unique column, then you can look up the UUID from the database and save it in another record. You cannot feasibly generate a duplicate UUID using Uuid:uuid4() without astronomical odds, however.

If you intend to use the UUID as a unique identifier, best practice would be to also add a unique constraint on your database column.