The difference between "and null" in the database

Source: Internet
Author: User

Null is not an object, ' is an object
From ', you can know that this is a string type of data and is a zero-length string.
From NULL, you can only know that there is no value assigned, is empty, he does not belong to any data type.

In the actual use of the database, we generally put the string variable default to ' ', the numeric variable default is 0, so as to guarantee that the logical operation is not produced a type mismatch error.
The functions in SQL Server are: ISNULL (variables, values),
Such as
For integer variables, this goes to the operation:
SET @VAR =1+isnull (integer variable, 0)
For a character variable, this goes to the operation:
SET @VAR =isnull (character variable, ")

Ünull is not a value, it indicates that the value is unknown or indeterminate

Ünull is a property that indicates that no content is in it, while NULL indicates that the value is empty, but has a default value, possibly 0.

Ünull's judgment cannot be simply used = or! = can only be judged by using is (not) null. So it's not null and the result of!=null is completely different. Although!=null compilation does not make an error, no one can judge a field as null

ü In the database, null values are used to indicate an unknown or meaningless condition of the actual value. Because null values represent the absence of data, null values and other values are not comparable, that is, they cannot be compared with equals, not equals, greater than or less than other numeric values, and of course also include the null itself (except in decode, where two null values are considered equivalent). The test null value can only be used with the comparison operator is null and is not NULL. If you use a conditional expression with another comparison operator, and the result depends on a null value, the result must be null. In the Where condition, the condition that Oracle considers the result to be NULL is false, and a SELECT statement with such a condition does not return a row and does not return an error message.

ü Adding or modifying a record when a field is ' ', this field in the database is null (the default value of the database is also null) when queried, it cannot be used in a way that can only be null or is NOT NULL???

ü The difference between the three is:
IsNull is a type test that tests whether it is a null value (NULL) type.
IsEmpty is a value test that tests whether it is a null value. But the methods used in this different language are different.
= "" is a string test, testing whether the value is a null value.

When you create a database, a not NULL is defined for a field, but the empty string "can be written successfully when the data is written:

An empty (null) value indicates that the numeric value is unknown. A null value differs from a blank or 0 value. There are two equal null values. The comparison of two null values, or null values, is unknown compared to any other value, because each null value is unknown.

The empty string ' is also a definite value when writing data, so you can write it even if you define not NULL.

U say in the definition that null values are not equal to any value. Therefore, you cannot use = NULL to make a judgment. In an SQL statement, the only value that can be used = NULL is the assignment statement in the UPDATE statement, which is not available elsewhere.

The difference between "and null" in the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.