MySQL 中NULL和空值的区别

如题所述

首先,我们需要搞清楚 "空值" 和"NULL"的概念:
1:空值('')是不占用空间的
2: MySQL中的NULL其实是占用空间的。官方文档说明:
“NULL columns require additional space in the row to record whether their values are NULL. For MyISAM tables, each NULL column takes one bit extra, rounded up to the nearest byte.”
长度验证:注意空值的''之间是没有空格的。
mysql> select length(''),length(null),length(' ');
+------------+--------------+--------------+
| length('') | length(null) | length(' ') |
+------------+--------------+--------------+
| 0 | NULL | 2 |
+------------+--------------+--------------+
温馨提示:答案为网友推荐,仅供参考
相似回答