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 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短