Home > Blockchain >  Oracle SQL how to export null values
Oracle SQL how to export null values

Time:05-14

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.

CodePudding user response:

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;

CodePudding user response:

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>)
  • Related