66.笔记 MySQL学习——MySQL的BIT数据类型

来源:互联网 发布:淘宝店主自拍技巧 编辑:程序博客网 时间:2024/05/22 06:59

66.笔记 MySQL学习——MySQL的BIT数据类型

创建一个表如下:

create table t (b bit(3));

执行插入,查询:

MariaDB [mytest]> insert into t(b) values(0),(b'11'),(b'101'),(b'111');

Query OK, 4 rows affected (0.06 sec)

Records: 4 Duplicates: 0  Warnings: 0

 

MariaDB [mytest]> select b+0,cast(b as unsigned)from t;

+------+---------------------+

| b+0 | cast(b as unsigned) |

+------+---------------------+

|   0 |                   0 |

|   3 |                   3 |

|   5 |                   5 |

|   7 |                   7 |

+------+---------------------+

4 rows in set (0.03 sec)

 

 

 

 

 

原创粉丝点击