Uoj
Uoj

Reputation: 45

MongoDB generate UUID with dashes

I need to add random UUID with dashes to my column GUID. How I should write my sql script, I was using GUID = MD5(UUID()); but it generates UUID without dashes, what would be solution ?

Upvotes: 1

Views: 445

Answers (1)

MSalters
MSalters

Reputation: 179809

If you use MD5(UUID()), it no longer is a UUID, and the "guaranteed unique" property is also lost. Don't do that.

That said, a UUID is a 128 bits number. It doesn't have dashes. Some representations do, but that's a display issue.

Upvotes: 1

Related Questions