Can someone please explain the differences between Null, Zero and Blank in SQL to me?
-
1Blank (or space) is a character. Zero is a number. Null means "no value". – Stephen C Sep 06 '17 at 03:23
-
Blank could also be an empty string. It depends on the context. – Stephen C Sep 06 '17 at 03:33
-
You should demonstrate that you've put at least a little bit of effort into your question before you ask it. – Jacobm001 Sep 06 '17 at 04:06
4 Answers
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:
- AFAIK, there is no SQL or MySQL specific technical meaning for "blank". (Try searching the online MySQL manual ...)
- For some people "blank" could mean a zero length string value: i.e. one with no characters in it (
''
). - For some people "blank" 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), some people could use "blank" to mean a non-printing character value.
- For some people could even use "blank" mean "anything that doesn't show up when you print or display it".
- And then there are meanings that are specific to (for example) ORM mappings.
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.

- 698,415
- 94
- 811
- 1,216
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:
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.

- 1,183
- 1
- 10
- 25
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

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

- 127
- 2
- 8