
BOOL和BOOLEAN都像TINYINT(1)一样工作。你可以说它们都是TINYINT(1)的同义词。 BOOLEAN这是BOOLEAN的一个例子。创建一个具有boolean类型列的表的查询。 mysql> create table Demo
-> (
-> isVaidUser boolean
-> );
Query OK, 0 rows affected (1.08 sec) 登录后复制 使用插入命令将记录插入表中的查询如下 − mysql> insert into Demo values(true);
Query OK, 1 row affected (0.19 sec)
mysql> insert into Demo values(0);
Query OK, 1 row affected (0.17 sec) 登录后复制 使用select命令显示表中的所有值。查询如下 − mysql> select *from Demo; 登录后复制 输出+------------+
| isVaidUser |
+------------+
| 1 |
| 0 |
+------------+
2 rows in set (0.00 sec) 登录后复制 登录后复制 BOOL这是BOOL的一个例子。以下是创建表的查询− mysql> create table Demo1
-> (
-> isVaidUser bool
-> );
Query OK, 0 rows affected (0.54 sec) 登录后复制 使用插入命令在表中插入记录。查询如下 − mysql> insert into Demo1 values(1);
Query OK, 1 row affected (0.14 sec)
mysql> insert into Demo1 values(false);
Query OK, 1 row affected (0.16 sec) 登录后复制 使用select命令显示表中的所有值。查询如下 − mysql> select *from Demo1; 登录后复制 输出+------------+
| isVaidUser |
+------------+
| 1 |
| 0 |
+------------+
2 rows in set (0.00 sec) 登录后复制 登录后复制 Look at the sample output, false is converted to 0. That means BOOL and BOOLEAN implicitly convert into tinyint(1). |