Is there a difference between Binary (16) and VarBinary (16) in MySQL

Nhibernate has a problem with varbinary (16) when tring represents Guids. I would think that varbinary (16) and binary (16) are the same thing.

+3
source share
3 answers

binary (16) - fixed length. It always uses 16 bytes of memory for each row, filling in any additional bytes 0x00 or 0x20 (depending on the version of MySQL) and deleting them on SELECT. varbinary uses a variable amount of space - all that is needed to store data on this line.

If your data is always 16 bytes, there is no difference. Actually, probably, there is no difference with a small column.

+4

MySQL: BINARY VARBINARY

" BINARY , ... VARBINARY ."

0

To expand on this, the difference between VAR_TYPE_ and TYPE (where TYPE is something like CHAR, INT, BINARY, etc.), is that the non-VAR version will be filled to full length, specify (if necessary ) VAR- will not be supplemented, which makes it suitable for storing text comments, etc.

0
source

Source: https://habr.com/ru/post/1715444/


All Articles