mysql bit类型 使用select查询无法看到其值
解決:
1、查詢十進制:+0
?select id+0 from table;? ??
2、查詢二進制:
?select bin(id+0) from test;?
3、查詢八進制:
?select oct(id+0) from test;
4、查詢十六進制:
?select hex(id+0) from test;?
?
補充:
創建bit類型字段
其中括號里的8表示二進制長度。如8表示最大為11111111,插入的值超過這個會被設為255;
CREATE TABLE t (b BIT(8));
插入:
INSERT INTO t SET b = b'11111111';
select b+0 from t;
mysql> select b+0,bin(b+0),oct(b+0),hex(b+0) from t;
+------+---
-------+----------+----------+
| b+0 ?| bin(b+0) | oct(b+0) | hex(b+0) |
+------+----------+----------+----------+
| ? 10 | 1010 ? ? | 12 ? ? ? | A ? ? ? ?|
+------+----------+----------+----------+
1 row in set (0.00 sec)
?
總結
以上是生活随笔為你收集整理的mysql bit类型 使用select查询无法看到其值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql的binary、char、va
- 下一篇: ofstream与ate的故事