COUNT(expresion) returns the count of of rows where expresion is not null. So SELECT COUNT (COL_NAME) FROM TABLE WHERE COL_NAME IS NULL will return 0, because you are only counting col_name where col_name is null, and a count of nothing but nulls is zero. COUNT(*) will return the number of rows of the query:

SELECT COUNT (*) FROM TABLE WHERE COL_NAME IS NULL

The other two queries are probably not returning any rows, since they are trying to match against strings with one blank character, and your dump query indicates that the column is actually holding nulls.

If you have rows with variable strings of space characters that you want included in the count, use:

SELECT COUNT (*) FROM TABLE WHERE trim(COL_NAME) IS NULL

trim(COL_NAME) will remove beginning and ending spaces. If the string is nothing but spaces, then the string becomes '' (empty string), which is equivalent to null in Oracle.

Answer from Shannon Severance on Stack Overflow
๐ŸŒ
Oracle Tutorial
oracletutorial.com โ€บ home โ€บ oracle basics โ€บ oracle is null operator
Oracle IS NULL Operator
April 27, 2025 - The following query uses the IS NULL operator to retrieve all orders that do not have a dedicated salesman: SELECT * FROM orders WHERE salesman_id IS NULL ORDER BY order_date DESC;Code language: SQL (Structured Query Language) (sql)
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
SELECT column_names FROM table_name ... a selection from the Customers table used in the examples: The IS NULL operator is used to test for empty values (NULL values)....
Top answer
1 of 11
92

Let's say that the record comes from a form to gather name and address information. Line 2 of the address will typically be blank if the user doesn't live in apartment. An empty string in this case is perfectly valid. I tend to prefer to use NULL to mean that the value is unknown or not given.

I don't believe the physical storage difference is worth worrying about in practice. As database administrators, we have much bigger fish to fry!

2 of 11
28

I do not know about MySQL and PostgreSQL, but let me treat this a bit generally.

There is one DBMS namely Oracle which doesn't allow to choose it's users between NULL and ''. This clearly demonstrates that it is not necessary to distinguish between both. There are some annoying consequences:

You set a varchar2 to an empty string like this:

Update mytable set varchar_col = '';

the following leads to the same result

Update mytable set varchar_col = NULL;

But to select the columns where the value is empty or NULL, you have to use

select * from mytable where varchar_col is NULL;

Using

select * from mytable where varchar_col = '';

is syntactically correct, but it never returns a row.

On the other side, when concatenating strings in Oracle. NULL varchars are treated as empty strings.

select NULL || 'abc' from DUAL;

yields abc. Other DBMS would return NULL in these cases.

When you want to express explicitly, that a value is assigned, you have to use something like ' '.

And you have to worry whether trimming not empty results in NULL

select case when ltrim(' ') is null then 'null' else 'not null' end from dual

It does.

Now looking at DBMS where '' is not identical to NULL (e.g. SQL-Server)

Working with '' is generally easier and in most case there is no practical need to distinguish between both. One of the exceptions I know, is when your column represents some setting and you have not empty defaults for them. When you can distinguish between '' and NULL you are able to express that your setting is empty and avoid that the default applies.

๐ŸŒ
SQLServerCentral
sqlservercentral.com โ€บ forums โ€บ topic โ€บ oracle-empty-string-is-the-same-as-null
Oracle empty string ('') is the same as NULL โ€“ SQLServerCentral Forums
October 11, 2010 - In Oracle, the NVL function is equivilent to the ISNULL function in SQL. One of the wierd things in Oracle is that an empty string ('') is considered NULL, which is not the same behavior that SQL treats an empty string.
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ database โ€บ other-databases โ€บ nosql-database โ€บ 20.3 โ€บ sqlreferencefornosql โ€บ is-null-and-is-not-null-operators.html
IS NULL and IS NOT NULL Operators
The IS NULL operator tests whether the result of its input expression is NULL. If the input expression returns more than one item, an error is raised. If the result of the input expression is empty, IS NULL returns false. Otherwise, IS NULL returns true if and only if the single item computed ...
๐ŸŒ
Use The Index, Luke
use-the-index-luke.com โ€บ sql โ€บ where-clause โ€บ null
NULL in the Oracle Database: Even more special than SQL NULL
Consequently, no value can be NULL. Instead the Oracle database treats an empty string as NULL: SELECT '0 IS NULL???' AS "what is NULL?" FROM dual WHERE 0 IS NULL UNION ALL SELECT '0 ...
Find elsewhere
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ database โ€บ oracle โ€บ oracle-database โ€บ 19 โ€บ sqlrf โ€บ Nulls.html
SQL Language Reference
September 24, 2025 - If you use any other condition with nulls and the result depends on the value of the null, then the result is UNKNOWN. Because null represents a lack of data, a null cannot be equal or unequal to any value or to another null. However, Oracle considers two nulls to be equal when evaluating a DECODE function. Refer to DECODE for syntax and additional information. Oracle also considers two nulls to be equal if they appear in compound keys.
๐ŸŒ
TechOnTheNet
techonthenet.com โ€บ oracle โ€บ isnotnull.php
Oracle / PLSQL: IS NOT NULL Condition
INSERT INTO suppliers (supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE account_no IS NOT NULL; This Oracle IS NOT NULL example will insert records into the suppliers table where the account_no does not contain a null value in the customers table.
๐ŸŒ
TechOnTheNet
techonthenet.com โ€บ oracle โ€บ isnull.php
Oracle / PLSQL: IS NULL Condition
UPDATE suppliers SET name = 'Apple' WHERE name IS NULL; This Oracle IS NULL example will update records in the suppliers table where the name contains a null value.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ sql queries โ€บ find null or empty values in sql
Find Null or Empty Values in SQL Baeldung on SQL
August 20, 2025 - SELECT id, name FROM Department WHERE code IS NULL OR TRIM(code) = ''; The TRIM function removes whitespaces from a stringโ€™s beginning and end, allowing us to compare it against an empty character. ... The COALESCE function in SQL returns the first non-NULL value from a list of arguments.
๐ŸŒ
Oracle
docs.oracle.com โ€บ cd โ€บ E40521_01 โ€บ server.761 โ€บ es_eql โ€บ src โ€บ reql_sets_is_empty.html
IS_EMPTY and IS_NOT_EMPTY functions
The IS_EMPTY and IS_NOT_EMPTY functions determine whether a set is or is not empty. The IS EMPTY and IS NOT EMPTY functions provide alternative syntaxes for these functions. Note: The IS NULL and IS NOT NULL operations are not supported on sets.
๐ŸŒ
DZone
dzone.com โ€บ data engineering โ€บ databases โ€บ null in oracle
NULL in Oracle
August 17, 2023 - Due to the peculiarities of the three-valued logic, NOT IN is not friendly with NULLs at all: as soon as NULL gets into the selection conditions, do not wait for the data. Here Oracle deviates from the ANSI SQL standard and declares the equivalence of NULL and the empty string.
๐ŸŒ
Red Gate Software
red-gate.com โ€บ home โ€บ checking for null with oracle sql
Checking for NULL with Oracle SQL - Simple Talk
July 14, 2021 - NULL is undefined. But you need to work with NULL values (which are no actual values). Luckily Oracle provides us with a couple of functions to do the heavy lifting when it comes to checking for NULLs.