As I understand UUID v4 is set as a standard.
Should we use before without «-» or we put it with «-» and uppercased?
Need help.
Generally a UUID uses dashes and lowercase, i.e., 1094105c-8133-4050-b2c4-c0e03f1ad23c
.
Your question lacks a bit of context. Why do you think <<->>
is needed at all? What does that even mean? I am guessing you are looking at some kind of output that shows brackets?
In any event, generating uuids can be trickier than they seem. Might be best to use a library just to get started. Symfony libraries are well known. From an empty directory:
composer require symfony/uid
===
# uuid.php
<?php
require 'vendor/autoload.php';
use Symfony\Component\Uid\Uuid;
$uuid = Uuid::v4();
echo $uuid . "\n";
===
:~/ws2023/uuid$ php uuid.php
2ce2dc9b-63af-4758-9803-ed54911eaa11
No need for brackets or upper casing. Just use the value as is.
As the docs show there are several other defined versions of uuid but v4 is probably your best bet.
Thank you for the message. Yes, I just wanted to mark - not <<->>
.
Sorry for the confusion.
In which cases should be used UUID as id (primary key)?
Have you just not looked it up? Here is a wikipedia article that talks about the history, formats (what characters can be used) the different versions and… its use cases.