Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Nhibernate seems to have a problem with varbinary(16) when tring to represent Guids. I would have thought that varbinary(16) and binary(16) equate to the same thing.

like image 980
Nathan Fisher Avatar asked Jul 17 '26 06:07

Nathan Fisher


1 Answers

binary(16) is fixed length. It always uses 16 bytes of storage for each row, padding any extra bytes with 0x00 or 0x20 (depending on the version of MySQL) and stripping them on SELECT. varbinary uses a variable amount of space--whatever is needed to store the data on that row.

If your data are always exactly 16 bytes, there is no difference. Realistically, there probably isn't a difference anyway with a column that small.

like image 176
richardtallent Avatar answered Jul 19 '26 19:07

richardtallent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!