gpt4 book ai didi

mysql - mysql中NULL和Empty有什么区别

转载 作者:IT王子 更新时间:2023-10-29 00:38:10 25 4
gpt4 key购买 nike

Mysql 中 NULL 和 Empty String 有什么区别?

需要多少存储空间?

例如.

在用户表中

name : NULL - 占用多少空间

电话:-占用多少空间

最佳答案

考虑 NULL 的最佳方式是它是有毒的。

任何使用 NULL 完成的操作都会产生 NULL。

NULL + 任何数字类型为空。 NULL concat 任意字符串为空。

空字符串是长度为0的字符串。

例子:

mysql> select concat('hello world', null);
+-----------------------------+
| concat('hello world', null) |
+-----------------------------+
| NULL |
+-----------------------------+

mysql> select concat('hello world', '');
+---------------------------+
| concat('hello world', '') |
+---------------------------+
| hello world |
+---------------------------+

至于节省空间,这取决于定义列的数据类型。

关于mysql - mysql中NULL和Empty有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1840510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com