NOT EQUAL operator != not working as expected in Oracle

Mav*_*ven 0 sql oracle oracle10g

I have made a new column in my database table:

alter table TABLE add (COLUMN NUMBER(1));
Run Code Online (Sandbox Code Playgroud)

Now I want to select all records where the value of column is not zero, either it’s some other number of empty (null)

SELECT * FROM TABLE WHERE COLUMN != 0;
Run Code Online (Sandbox Code Playgroud)

And by default all columns have empty/null value as this column is recently added so it should return all records but doesn’t return any.

But if a change the value for this column of a record to 0 and run below query it works fine.

SELECT * FROM TABLE WHERE COLUMN = 0;
Run Code Online (Sandbox Code Playgroud)

Please help I want to select all records where the value is not 0.

Mah*_*kar 5

For NULL values you have to explicitly give IS NULL or IS NOT NULL

SELECT * FROM TABLE WHERE COLUMN <> 0 OR COLUMN IS NULL;
Run Code Online (Sandbox Code Playgroud)

OR

SELECT * FROM TABLE WHERE NVL(COLUMN,1) <> 0
Run Code Online (Sandbox Code Playgroud)

The Optimizer is going to do like in the first case even if you go with NVL()