Generate UUID version 4 or version 7. Version 4 is random. Version 7 starts with the current time, so newer ids sort after older ones.
A UUID is 128 bits written as hex. Version 4 is random, which is what most databases still ask for. Version 7 puts the Unix time in milliseconds in the front, so ids created later sort after earlier ones in a text or index order. This page generates them in the browser. It does not check whether an id you already have is unique in your database.
{ and }. “urn:uuid: prefix” adds that scheme in front.With hyphens, the form is 8-4-4-4-12. The version nibble is 4 or 7. The variant nibble is the RFC 4122 value, so the first hex digit of the fourth group is 8, 9, a or b. Version 7’s first 48 bits are the current Unix time in milliseconds, which is why two ids made a millisecond apart sort in time order when compared as text. The rest is random. The page uses the browser’s cryptographic random source when it is available.
Version 4 has 122 random bits. A match is not a practical concern. Version 7 can share the timestamp prefix in the same millisecond and still differ in the random tail.
No. A UUID identifies a row. Do not use it as a password or as an access token.