将列设置为BOOLEAN以显示0和1值。让我们创建一个表-
create table DemoTable2035 -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> isMarried boolean, -> PRIMARY KEY(Id) -> );
使用插入命令在表中插入一些记录-
insert into DemoTable2035(Name,isMarried) values('Chris',true); insert into DemoTable2035(Name,isMarried) values('David',false); insert into DemoTable2035(Name,isMarried) values('Bob',true); insert into DemoTable2035(Name,isMarried) values('Mike',false);
使用select语句显示表中的所有记录-
select *from DemoTable2035;
这将产生以下输出-
+----+-------+-----------+ | Id | Name | isMarried | +----+-------+-----------+ | 1 | Chris | 1 | | 2 | David | 0 | | 3 | Bob | 1 | | 4 | Mike | 0 | +----+-------+-----------+ 4 rows in set (0.00 sec)