What are the differences between Null, Zero and Bl

2020-02-16 05:03发布

Can someone please explain me?

标签: mysql sql
4条回答
Animai°情兽
2楼-- · 2020-02-16 05:34

Zero is a number value. It is a definite with precise mathematical properties. (You can do arithmetic on it ...)

NULL means the absence of any value. You can't do anything with it except test for it.

Blank is ill-defined. It means different things in different contexts to different people. For example:

  • Someone could mean a zero length string value: i.e. one with no characters in it ('').
  • Someone could mean a non-zero length string value consisting of only non-printing characters (SPACE, TAB, etc). Or maybe consisting of just a single SPACE character.
  • In some contexts (where character and string are different types), someone could mean a non-printing character value.
  • Someone could even mean "anything that doesn't show up when you print or display it".

The point is that "blank" does not have a single well-defined meaning. At least not in (native) English IT terminology. It is probably best to avoid it ... if you want other IT professionals to understand what you mean. (And if someone else uses the term and it is not obvious from the context, ask them to say precisely what they mean!)


We cannot say anything generally meaningful about how ZERO / NULL / BLANK are represented, how much memory they occupy or anything like that. All we can say is that they are represented differently to each other .... and that the actual representation is implementation and context dependent.

查看更多
我命由我不由天
3楼-- · 2020-02-16 05:42

Could you be more accurate about blank?

For what I understand of your question: "Blank" is the lack of value. This is a human concept. In SQL, you need to fill the field with a value anyway. So that there is a value which means "no value has been set for this field". It is NULL. If Blank is "", then it is a string, an empty one. Zero: well, Zero is 0 ... It is a number.

To sum up:

NULL --> no value set

Blank ("") --> empty string

Zero --> Number equal to 0

Please, try to be more accurate next time you post an answer on Stack!

If I were you, I would check some resources about it, for example: https://www.tutorialspoint.com/sql/sql-null-values.htm

查看更多
Summer. ? 凉城
4楼-- · 2020-02-16 05:46

You may correlate NULL-BLANK-ZERO case by child birth scenario( A real life Example.).

NULL Case: Child is not born yet.

BLANK Case: Child is born but we didn't give any name to him

ZERO Case: We defined it as zero, Child is born but of zero age. See how this data will look in a database table:

enter image description here

Also NULL is a absence of value, where a field having NULL is not allocated any memory, where as empty fields have empty value with allocated space in memory.

查看更多
我只想做你的唯一
5楼-- · 2020-02-16 05:47

NULL means it does not have any value not even garbage value. ZERO is an integer value. BLANK is simply a empty String value.

查看更多
登录 后发表回答