mysql boolean类型default 0/1 not true,false
来源:互联网 发布:vue.js视频教程百度云 编辑:程序博客网 时间:2024/05/16 09:49
You have to specify 0 (meaning false) or 1 (meaning true) as the default. Here is an example:
);
FYI: boolean is an alias for tinyint(1).
mysql> create table mytable (
-> mybool boolean not null default 0
-> );
Query OK, 0 rows affected (0.35 sec)
mysql> insert into mytable () values ();
Query OK, 1 row affected (0.00 sec)
mysql> select * from mytable;
+--------+
| mybool |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
FYI: My test was done on the following version of MySQL:
mysql> select version();
+----------------+
| version() |
+----------------+
| 5.0.18-max-log |
+----------------+
create table mytable (
mybool boolean not null default 0);
FYI: boolean is an alias for tinyint(1).
mysql> create table mytable (
-> mybool boolean not null default 0
-> );
Query OK, 0 rows affected (0.35 sec)
mysql> insert into mytable () values ();
Query OK, 1 row affected (0.00 sec)
mysql> select * from mytable;
+--------+
| mybool |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
FYI: My test was done on the following version of MySQL:
mysql> select version();
+----------------+
| version() |
+----------------+
| 5.0.18-max-log |
+----------------+
1 row in set (0.00 sec)
在mysql中设置字段类型为boolean。mysql会自动变成tinyint(1)。明白了为什么default value 为0/1。
- mysql boolean类型default 0/1 not true,false
- 前台中: 1 和 0 传入到 vo 中 boolean 类型的是 true 还是 false?
- boolean b=true?false:true==true?false:true;
- 0是FALSE 1是TRUE
- PL/SQL的BOOLEAN的三个值:TRUE,FALSE,NULL
- js中Boolean值为false和true的情况:
- 读取Mysql bit(1) 的true或者false借用char
- 逻辑运算中true和false的数字表现形式true=1 false=0
- 雅思技巧(True , False , Not given)
- String类型的Hello返回 true | false
- MySQL数据库中字段类型为tinyint,读取出来为true/false的问题
- MySQL数据库中tinyint类型字段读取数据为true和false
- MySQL数据库中tinyint类型字段读取数据为true和false
- MySQL数据库中tinyint类型字段读取数据为true和false
- ActionScript中false==0, true==1
- numpy中的True/False如何转化成1/0
- True/False
- MySql 中的 boolean 类型设置
- __init和__exit宏
- 模式匹配
- 微博
- 接触Dojo,从HelloWorld开始
- JSP
- mysql boolean类型default 0/1 not true,false
- NHibernate + SQLite + MVC 开发记录 四
- NHibernate + SQLite + MVC 开发记录 五
- GPL v2
- win7下myeclipse部署nutch1.3报Expecting a line not the end of stream异常解决
- 工程硕士之旅
- 空间分割加速三维数据的查询
- NHibernate + SQLite + MVC 开发记录 六
- MySql服务无法启动系统出错发生系统错误1067进程意外终止