Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best datatype to store UUIDs in PostgreSQL?

I am trying to store UUIDs in a posts table (posts - social media like it doesn't matter), and I would like to know which is the correct way to store UUIDs in PostgreSQL. I have tried to convert them into bytes and store them into binary(16) datatype columns in MySQL. But I cannot find a similar type in PostgreSQL such as binary(16) I found only bytea. So I need a datatype that will help with the size of the column. Is there anything like bytea var-sized?

like image 536
Monsta Avatar asked Sep 17 '25 18:09

Monsta


1 Answers

Use the dedicated uuid datatype. Not bytes or bits.

like image 151
Bergi Avatar answered Sep 19 '25 09:09

Bergi