Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle 10g: column is blank, but is not null or an empty string

Tags:

sql

oracle

I have a column in a table that is blank. The weird thing is that it does not appear to be null or an empty string. So, if I do this:

SELECT * 
  FROM TABLE 
 WHERE column IS NULL

...or:

SELECT * 
  FROM TABLE 
 WHERE column = ''

I get nothing. Thoughts?

like image 232
Josh Avatar asked Jan 25 '11 16:01

Josh


4 Answers

Issue this query:

SELECT column, DUMP(column, 1016)
FROM table

It'll show the exact contents.

Related: Oracle does not allow empty strings; they're silently converted to NULL.

like image 141
Álvaro González Avatar answered Sep 23 '22 18:09

Álvaro González


Maybe the column contains only spaces?

Did you try

select * 
from table 
where trim(column) is null
like image 38
a_horse_with_no_name Avatar answered Sep 24 '22 18:09

a_horse_with_no_name


Oracle's got a basically permanent annoyance that empty strings are treated as null. However, are you sure that's an empty string? It could be an otherwise invisible character, such as a space or tab/linebreak/linefeed/etc... What does the string length show when you do select length(column) from table?

like image 28
Marc B Avatar answered Sep 26 '22 18:09

Marc B


Try this:

SELECT *    
  FROM TABLE   
 WHERE TRIM(column) IS NULL
like image 43
Chandu Avatar answered Sep 26 '22 18:09

Chandu