MySQL 中NULL和空值的区别
eg:
ERROR 1048 (23000): Column 'c' cannot be null
+-----------+-----------+
| length(b) | length(c) |
+-----------+-----------+
| 2 | 0 |
| 0 | 0 |
| NULL | 0 |
| NULL | 0 |
| 4 | 2 |
+-----------+-----------+
5 rows in set (0.00 sec)
+----------+----------+
| count(b) | count(c) |
+----------+----------+
| 3 | 5 |
+----------+----------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.07 sec)
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| testbb | CREATE TABLE `testbb` (
`a` int(11) NOT NULL,
`b` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Query OK, 1 row affected, 1 warning (0.00 sec)
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'b' at row 1 |
+---------+------+----------------------------------------+
+---+---------------------+
| a | b |
+---+---------------------+
| 1 | 2014-08-15 14:32:10 |
| 2 | 0000-00-00 00:00:00 |
+---+---------------------+
2 rows in set (0.00 sec)
MySQL 中NULL和空值的区别的更多相关文章
- MySQL 中NULL和空值的区别 (转载 http://blog.sina.com.cn/s/blog_3f2a82610102v4dn.html)
平时我们在使用MySQL的时候,对于MySQL中的NULL值和空值区别不能很好的理解.注意到NULL值是未知的,且占用空间,不走索引,DBA建议建表的时候最好设置字段是NOT NULL 来避免这种低效 ...
- MySQL 中NULL和空值的区别,索引列可以有空值或者null吗?
空值跟null的区别.mysql官方: “NULL columns require additional space in the row to record whether their values ...
- 【面试】MySQL 中NULL和空值的区别?
做一个积极的人 编码.改bug.提升自己 我有一个乐园,面向编程,春暖花开! 01 小木的故事 作为后台开发,在日常工作中如果要接触Mysql数据库,那么不可避免会遇到Mysql中的NULL和空值.那 ...
- mysql中null与“空值”的坑
https://blog.csdn.net/u014743697/article/details/54136092
- 用count(*)还是count(列名) || Mysql中的count()与sum()区别
Mysql中的count()与sum()区别 首先创建个表说明问题 CREATE TABLE `result` ( `name` varchar(20) default NULL, `su ...
- MySQL中interactive_timeout和wait_timeout的区别【转】
在用mysql客户端对数据库进行操作时,打开终端窗口,如果一段时间没有操作,再次操作时,常常会报如下错误: ERROR 2013 (HY000): Lost connection to MySQL s ...
- MySQL中 utf8与utf8mb4的区别
MySQL中 utf8与utf8mb4的区别 一.简介 MySQL在5.5.3之后增加了这个utf8mb4的编码,mb4就是most bytes 4的意思,专门用来兼容四字节的unicode.好在 ...
- (转)MySQL中In与Exists的区别
背景:总结mysql相关的知识点. 如果A表有n条记录,那么exists查询就是将这n条记录逐条取出,然后判断n遍exists条件. select * from user where exists s ...
- Mysql中函数和存储过程的区别
Mysql中函数和存储过程的区别 存储过程: 1. 可以写sql语句 2. inout,out构造返回值 3. 调用:call:存储过程名称 4. 可以 ...
随机推荐
- BZOJ 1103: [POI2007]大都市meg
1103: [POI2007]大都市meg Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2189 Solved: 1160[Submit][Sta ...
- 【BZOJ-1069】最大土地面积 计算几何 + 凸包 + 旋转卡壳
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 2707 Solved: 1053[Submit][Sta ...
- 【BZOJ-2440】完全平方数 容斥原理 + 线性筛莫比乌斯反演函数 + 二分判定
2440: [中山市选2011]完全平方数 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2371 Solved: 1143[Submit][Sta ...
- springMVC-数据的格式化
1.配置annotation-driven <mvc:annotation-driven ></mvc:annotation-driven> 2.在实体类上加上@NumberF ...
- 【codevs1993】 草地排水
http://codevs.cn/problem/1993/ (题目链接) 题意 求有向图最大流. Solution Dinic. 代码 // codevs1993 #include<algor ...
- 【poj1019】 Number Sequence
http://poj.org/problem?id=1019 (题目链接) 题意 给出一个数:1 12 123 1234 12345 123456 1234567 12345678 123456789 ...
- exists的用法
今天突然看到之前自己写的一个代码 久久没想通为毛.. 看来笔记还是需要 exists可以代替子查询in 比in 更高效 默认是exists 查询中包含有数据则条件成立..否则没数据 select ...
- vijos2001 xor-sigma
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转 ...
- 利用iconv进行文件编码批量原地转换
将当前目录及其所有子目录中的以 java 为后缀的文件,从 GB18030 转换为 UTF-8: find . -name "*.java" -exec sh -c " ...
- 计算机组成原理 及CPU,硬盘,内存三者的关系
前面提到了,电脑之父——冯·诺伊曼提出了计算机的五大部件:输入设备.输出设备.存储器.运算器和控制器. 我们看一下现在我们电脑的: 键盘鼠标.显示器.机箱.音响等等. 这里显示器为比较老的CRT显示器 ...