MySQL 字段默认值 一般设null 还是空字符串?
高洛峰
高洛峰 2017-04-17 14:39:43
0
3
961

MySQL 字段默认值 一般设null 还是空字符串?设nul 和空字符串的区别是什么,各有什么优缺点。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
Ty80

Empty strings are OK, try not to use null. This is a keyword, which will be a pitfall in your future index optimization

洪涛

Not sure, but it seems like an empty string is stored. You can have a piece of data with a null value, and then check the type of the null field value. If it is string, it is an empty string, if not, it is null.
To put it simply,
var testString = ""; //This declares a testString string, equal to "", which is already stored in memory.
var testString = null; //This declares a testString variable, which is just a variable and does not actually allocate memory space.
If you don’t understand, just think about it this way. If you use a writing word to represent this process, "" means a blank piece of paper with no writing on it. And null means you don't even have a blank piece of paper.

大家讲道理

not null default ""

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template