Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between MySQL bit vs binary?

Tags:

mysql

We can store binary values using either binary or bit (up to 64 bits).

What is the difference between using binary(n) vs using bit(m) (where n = 8 × m)?

Are they recognized as the same thing by MySQL?

(Assuming using MySQL >= 5.0.3.)

like image 302
Pacerier Avatar asked Feb 14 '26 17:02

Pacerier


1 Answers

You can store bits using BIT or BINARY - as you want. The BIT data type may be more usable in logic operations.

There is a small difference in storage:

  • BINARY(M) requies exact number of bytes - M
  • the length of the BIT type may vary, find more information here - Data Type Storage Requirements.
like image 179
Devart Avatar answered Feb 17 '26 10:02

Devart



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!