Myth: Oracle Cannot Index NULL


The source of this myth is rather easy to understand when you look at the correctly expressed statement:

The Oracle database does not include rows into an index if all indexed columns are NULL.

The difference between the myth and the reality is small—it seems that the myth is a sloppy form of the truth.

The truth is that NULL can be indexed by adding another not nullable column to the index:

CREATE INDEX with_null ON table_name (nullable_column, '1');

Read Section 6.1 for the full story.

About the Author

Photo of Markus Winand
Markus Winand tunes developers for high SQL performance. He also published the book SQL Performance Explained and offers in-house training as well as remote coaching at http://winand.at/

?Recent questions at
Ask.Use-The-Index-Luke.com

0
votes
0
answers
87
views

index for better performance for a merge operation

21 hours ago Markus Winand ♦♦ 936
merge index
0
votes
0
answers
1.8k
views

Join with inequalities only

Dec 16 '14 at 12:06 Markus Winand ♦♦ 936
inequality join
0
votes
1
answer
807
views

PostgreSQL Scripts: Performance Testing and Scalability problem and question

Nov 12 '14 at 14:53 Markus Winand ♦♦ 936
testing postgresql scalability