postgresqltypesbinaryuuidbytea

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?


Solution

  • Use the dedicated uuid datatype. Not bytes or bits.