NULL behaviour in Oracle

NULL, as known in SQL, a special marker and keyword indicating that something has no value. A value of NULL is different from an empty or zero value. No two null values are equal. Comparisons between two null values, or between a NULL and any other value, return unknown because the value of each NULL is unknown. (ref -

For understanding it, I am using a practical approach where we play around NULL value, sorry No Value, with Oracle database.

** NULL value doesn't count in aggregate functions.
NULL value doesn't count by aggregate functions such as MAX, MIN, SUM, COUNT in SQL.


** Inserted null string converted to Null.


** Where can Null be compared?

Oracle SQL Reference says "In a DECODE function, Oracle considers two nulls to be equivalent. If expr is null, then Oracle returns the result of the first search that is also null."
But this therory varies with DB to DB internal architecture and the way they handled the NULL.Another place where Null can be compared is in range partition definition, where MAXVALUE is greater than Null

**  Unique constraints

You are able to insert another Null without getting ORA-1 (unique constraint violated).

So if all columns are null, the unique constraint will not be violated. If one or more columns have non-null values, the constraint takes effect.

** Unknown OR True returns True, Unknown AND False returns False

Like the below page to get update

No comments

Powered by Blogger.