Domanda

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?

È stato utile?

Soluzione

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;

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top