3

I am confuse about what is the value of NULL in SQL. NULL I think is empty.

So will it contain any garbage value or unknown value or like 0 in integer or blank in character?

3
  • @MTilsted: no it's not. It's the absence of a value. Commented Feb 24, 2014 at 12:27
  • 1
    @a_horse_with_no_name:- Yes very correct. Or better to say Unknown value as OP can misinterpret it and may think that it is the same as empty ;) Commented Feb 24, 2014 at 12:29
  • NULL is a value used to indicate that there is no domain specific value in the field. But I would still say that NULL itself is a value. Just try to ask a database admin what the default value is of a field, if no value is provided. And he will most likely answer null. Commented Feb 24, 2014 at 13:58

5 Answers 5

3

In simple worlds you can say that Null is not a data value, but a marker for an unknown value.

So any mathematical operations performed on NULL will result in NULL. For example,

10 + NULL = NULL

Similarly if you do string concatenation with string you get:-

'String ' || NULL || 'Concatenation' -- Result is NULL 

So you can say that Null means either "not applicable" or "don't know": it is not the same as zero (0) or any other default value, but more importantly, null is treated quite differently from other values in SQL, because it literally has no value.

An example to explain what it means when we say that NULL means UNKNOWN VALUE:

StudentName TestResult X 78 A 89 B 67 C NULL 

So you can see that the student C got NULL marks in the test. So what does that mean?

Now one can say that the student does not sit in the test or it may be that the student's data is not avaialable. But it definitely does not mean that the student got 0(as if you assign 0 to the student then it would mean that the student appeared in the test and got zero) marks in the test. All we can say that the data for the student is

UNKNOWN or NULL

Sign up to request clarification or add additional context in comments.

Comments

2

A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces.

If a column in a table is optional, we can insert a new record or update an existing record without adding a value to this column. This means that the field will be saved with a NULL value.

NULL values are treated differently from other values.

NULL is used as a placeholder for unknown or inapplicable values. Read more about this here.

1 Comment

NULLs are also generated by left joins. In some sense they are qualitatively different than the NULLs originally present in the data.
2

NULL is a keyword used to represent unknown/missing data.

Say you have an optional column in your table. You can insert a new record or update an existing record without adding a value to this column. This means that the field will be saved with a NULL value.

Check this for more details.

Comments

2

It is to indicate that a data value does not exist in the database.NULL is also an SQL reserved keyword used to identify the Null special marker.

NULL means “a missing unknown value” and it is treated somewhat differently from other values.

A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces.

10 * NULL -- Result is NULL 

Null (SQL)

SQL NULL

Working with NULL Values

Comments

1

Null is not empty actually but it is considered as uknown value, from dumentation

Conceptually, NULL means “a missing unknown value” and it is treated somewhat differently from other values.

You can ready more here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.