实际上,位值是作为二进制值返回的,但是我们还可以借助以下内容以可打印的形式显示它们:
我们可以通过将位值加0来以可打印的形式显示它们。以下来自bit_testing表的示例可用于理解它-
mysql> Select bittest+0 from bit_testing; +-----------+ | bittest+0 | +-----------+ | 170 | | 5 | | 5 | +-----------+ 3 rows in set (0.00 sec)
BIN()
,OCT(),HEX()我们还可以使用BIN()
转换功能以可打印的形式显示位值。以下来自bit_testing表的示例可用于理解它-
mysql> Select BIN(bittest+0) from bit_testing; +----------------+ | BIN(bittest+0) | +----------------+ | 10101010 | | 101 | | 101 | +----------------+ 3 rows in set (0.00 sec) mysql> Select OCT(bittest+0) from bit_testing; +----------------+ | OCT(bittest+0) | +----------------+ | 252 | | 5 | | 5 | +----------------+ 3 rows in set (0.05 sec) mysql> Select HEX(bittest+0) from bit_testing; +----------------+ | HEX(bittest+0) | +----------------+ | AA | | 5 | | 5 | +----------------+ 3 rows in set (0.00 sec)