虽然MySQL中没有boolean类型,在实际用的时候SQL也不会报错,如下所示:

  • drop table if exists Test;
  • create table Test
  • (
  • id int primary key,
  • `status` boolean default 1
  • ) ;

通过观察表的结构,发现boolean在MySQL里的类型为tinyint(1):

  • desc Test;

MySQL里有四个常量:true,false,TRUE,FALSE,它们分别代表1,0,1,0

标签: none

添加新评论