'Oracle SQL how to export null values

in relation with how to copy the records from output of oracle SQL developer to excel sheet

I'm using Oracle SQL developer. I've some queries which get some null values in the result grid. I'd cut/paste these values in Excel but null are pasted as empty, not as "null", so difficult to find them among cells that contains spaces. Is there any way to export null as "null" in Excel please?

Thank you.



Solution 1:[1]

If your column is of datatype varchar2 then:

select case  
            when your_column is null then 'null'
            else your_column  
       end your_column
from your_table;

If your column is of number or date datatype then just convert the non null values to string using to_char:

select case  
            when your_column is null then 'null'
            else to_char(your_column) 
       end your_column
from your_table;

Solution 2:[2]

You have multiple options:

  1. Using case with the IS NULL comparison
  2. Using NVL()
  3. Using DECODE() with something like DECODE(<col>, NULL, 'NULL', <col>)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gnqz