What are the differences and usage scenarios between mysql bit and tinyint?

tinyint

that has been used before for fields that represent data types or states

has not paid attention to the bit type. After consulting the data, we know that bit is stored in binary format: bounded 0" or bounded 1"
its storage unit is directly bit , while the smallest unit of tinyint is 1 byte.
however, some people say that bit does not support indexing. Source: [MySQL] stories triggered by bit types

personally, I think: because php is weakly typed, bit type query is not as convenient as tinyint ,

.

is said to be more suitable for java . If you have any trouble, explain why? And their differences and usage scenarios?


tinyint is a numeric type that stores decimals and generally corresponds to a small dictionary or enumeration type in the editing language. While saving space, avoid saving out-of-range values.
bit is similar to storing state. For example, bit (1) directly corresponds to the Boolean types true and false. of Java language. When using for state saving, a field can save up to 64 states.
if a system I developed needs to save the state of sending text messages to users, there are more than 10 different types of text messages, each of which should be marked whether they have been sent or not. It is very convenient to use the bit type at this time. Of course, it can also be achieved with int, but using bit is more semantic. You can do it bitwise when querying or updating a status.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e384b3-444bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e384b3-444bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?