Question

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?

Was it helpful?

Solution

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;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top