MySQL BOOL和BOOLEAN列数据类型之间有什么区别?
BOOL和BOOLEAN的行为都类似于TINYINT(1)。您可以说两者都是TINYINT(1)的同义词。
布兰
这是BOOLEAN的示例。用于创建具有列布尔类型的表的查询。
mysql> create table Demo -> ( -> isVaidUser boolean -> );
使用insert命令在表中插入记录的查询如下-
mysql> insert into Demo values(true); mysql> insert into Demo values(0);
使用选择命令显示表中的所有值。查询如下-
mysql> select *from Demo;
输出结果
+------------+ | isVaidUser | +------------+ | 1 | | 0 | +------------+ 2 rows in set (0.00 sec)
布尔
这是BOOL的示例。以下是创建表的查询-
mysql> create table Demo1 -> ( -> isVaidUser bool -> );
使用insert命令在表中插入记录。查询如下-
mysql> insert into Demo1 values(1); mysql> insert into Demo1 values(false);
使用选择命令显示表中的所有值。查询如下-
mysql> select *from Demo1;
输出结果
+------------+ | isVaidUser | +------------+ | 1 | | 0 | +------------+ 2 rows in set (0.00 sec)
查看示例输出,将false转换为0。这意味着BOOL和BOOLEAN隐式转换为tinyint(1)。
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短