空字段占用数据库中的空间吗? [英] Does an empty field take up space in database?
问题描述
我正在试图使表格规范化变得现实。我需要决定添加额外的字段 VARCHAR(255)
,大部分时间可能是空的,或者制作新的映射表存储该值加上相关的 id
I'm trying to be realistic about normalizing a table. I need to decide to add an extra field VARCHAR(255)
that will be probably empty most of the time, or make a new mapping table and store that value plus the relevant id there.
我的问题是,在第一种方法中,空值 VARCHAR (255)
字段占用数据库中的任何空间
My question is, in the first approach, does that empty VARCHAR(255)
field take up any space in the database?
平台:MySQL,InnoDB
Platform: MySQL, InnoDB
推荐答案
使用 NULL
。
在SQL中, null
不同于空字符串''
。
In SQL, null
is different from the empty string ''
.
空字符串
具体意味着值设置为空
虽然 null
表示值未设置
,或已设置为零。
The empty string
specifically means that the value was set to be empty
While null
means that the value was not set
, or was set to null.
这篇关于空字段占用数据库中的空间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!