关于数据库中的Empty / Blank,Null和Not Null数据 [英] about Empty/Blank, Null and Not Null data in database

查看:163
本文介绍了关于数据库中的Empty / Blank,Null和Not Null数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



Empty / Blank,Null和NotNull数据库字段有什么区别。

默认内存空间有多少由他们占用。



谢谢

Ravik

Hi guys,

What is the difference between Empty/Blank , Null and NotNull database field.
how many default memory space occupied by them.

Thanks
Ravik

推荐答案

没有特殊的空值或空白值。通常,不包含字符的字符串(char,varchar,nvarchar,text,stb ...)称为空或空白。但是空字符串不为空。 Null是一个特殊值,表示不填充任何数据的字段。这是没有。因此理论上空值不用于聚合计算,如果参与算术计算,它们会使整个公式未定义/为null(dbms实现可能会将空值略有不同)。

占用的空间是一个更复杂的问题。由于任何数据类型都可以保存空值(具体字段可能标记为不可为空,有时也可以标记为派生类型),因此数据库本身中空值占用的空间取决于数据类型。在标量或固定的最大宽度字符串(在这种情况下,char和varchar的行为方式相同)字段的情况下,空值或填充没有区别。对于未定义的可变长度字段(如TEXT(不建议使用)或VARCHAR(MAX)),空值将占用单个块。

在dbms和程序的内存中,它更加复杂。我不得不说,这取决于所使用的本机数据类型,当然还有编码器。

优化用于主要的dbms提供商,但大多数情况下性能比消耗的字节数。
There is no special empty or blank value. Usually string (char, varchar, nvarchar, text, stb...) fields that contain no characters are called empty or blank. But an empty string is not null. Null is a special value that denotes the field not to be populated with any data. It is "nothing". Thus theoretically null values are not used in aggregate calculations, and if involved in an arithmetical calculation they make the whole formula undefined/null (dbms implementation might treat null values slightly different).
The space occupied is a more complex question. Since any data type can hold null value (concrete fields might be marked as not nullable, sometimes derived types also), the space occupied by a null value in the database itself depends on the data type. In case of a scalar, or a fixed maximum width string (in this case char and varchar behave the same way) field, there is no difference with null value or filled. In case of undefined variable length fields like TEXT (deprecated) or VARCHAR(MAX), a null value will occupy a single block.
In the memory of the dbms and of the program it is even more complicated. I have to say, that it depends on the native data types used, and of course of the coder.
Optimization is used in case of the major dbms providers, but is most cases performance is more important than bytes consumed.


这篇关于关于数据库中的Empty / Blank,Null和Not Null数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆