1

If I'm understanding correctly, BIT is extremely disk efficient. For my case, I know I will always only have three values which I'd like to treat like INTs: 1, 2, & 3.

Am I correct that b'00' is 3 and different from b'0', 1?

If I try to use INT values for INSERT VALUEs and SELECT WHEREs, will mysql automatically cast as BITs in those queries?

  • This works, but it makes no sense to use a wrong type, when there's [TINYINT](http://dev.mysql.com/doc/refman/5.1/en/integer-types.html) also taking a single byte. – maaartinus May 27 '14 at 21:33

1 Answers1

1
insert into t (bits) values (b'11'); /* 3 = 2^1+2^0 */
insert into t (bits) values (b'10'); /* 2 = 2^1 */
insert into t (bits) values (b'1'); /*  1 = 2^0 */

Yes can insert INT;

b.b3rn4rd
  • 8,494
  • 2
  • 45
  • 57