I used to think that Oracle does not index a row when one of the column values is null.
Some simple experimentation shows this to be not the case. I was able to run some queries unexpectedly accessing only indexes even though some columns were nullable (which of course was a pleasant surprise).
A Google search led to some blogs with conflicting answers: I have read that a row gets indexed unless all indexed columns are null, and also that a row gets indexed unless the leading column value for the index is null.
So, in what cases does a row not enter an index? Is this Oracle version specific?
In addition to APC's answer, NULLS are indexed in bitmap indexes.
If any indexed column contains a non-null value that row will be indexed. As you can see in the following example only one row doesn't get indexed and that's the row which has NULL in both indexed columns. You can also see that Oracle definitely does index a row when the leading index column has a NULL value.
This example run on Oracle 11.1.0.6. But I'm pretty confident it holds true for all versions.
And in addition to APC's answer: when you want to index a NULL value, you can add a constant expression to the index.
Example:
Please note the full table scan and the 364 consistent gets.
And now it uses the index and has only 3 consistent gets.
Regards, Rob.