Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 2: Handling NULL Values

Lesson 18 of 28 in the free Database Management Systems notes on Siksha Sarovar, written by Rohit Jangra.

18.1 What is a NULL Value?

A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different from a zero value or a field that contains spaces. A NULL value is used to represent data that is missing, unknown, or not applicable.

18.2 Comparisons Using NULL

You cannot use comparison operators (like =, <, <>) with NULL.

  • Rule: Any arithmetic or comparison operation involving NULL results in UNKNOWN (which is effectively false for filtering).

How to Test for NULL:

To check for NULL values, use the IS NULL and IS NOT NULL operators.

Query TypeSyntax
Finding NullsSELECT * FROM Emp WHERE Comm IS NULL;
Finding Non-NullsSELECT * FROM Emp WHERE Comm IS NOT NULL;

18.3 Disallowing NULL Values

During table creation, you can specify that a column cannot accept NULL values by using the NOT NULL constraint.

18.4 Functions for NULL Handling

Most SQL dialects provide functions to handle NULLs gracefully during retrieval:

  • NVL(val, replacement) (Oracle)
  • IFNULL(val, replacement) (MySQL)
  • COALESCE(val1, val2, ...) (Standard SQL - returns the first non-null value).