Display numerical values without scientific notation in Oracle select

Asked

Viewed 3,466 times

0

I have to make several selects on Oracle using SQLPLUS displaying various information to be saved in text file. Some tables have numerical fields of type NUMBER(19). Some of these fields have values that are too high so that Oracle displays them in scientific notation as 8.0E+13. I know that if I use a to_char(field, '999999999999') I can format the field, but I don’t want to do that, because there are many tables and fields. Is there any way I can format the output so that all numeric fields are displayed without scientific notation? Follow an example code.

    create table teste_numerico(
      numero number(19)
    );

    insert into teste_numerico values (80000000003147);                      
    insert into teste_numerico values (80000000003153);                       
    insert into teste_numerico values (80000000003163);                     
    insert into teste_numerico values (80000000003170);                       
    insert into teste_numerico values (80000000003176);                       
    insert into teste_numerico values (80000000003181);                       
    insert into teste_numerico values (80000000003188);                       
    insert into teste_numerico values (80000000003194);                       
    insert into teste_numerico values (80000000003199);                       
    insert into teste_numerico values (80000000003206);                       
    insert into teste_numerico values (80000000003212);

Select without formatting:

    select *
      from teste_numerico;

Upshot:

        NUMERO
    ----------
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 
       8.0E+13 

     11 linhas selecionadas  

Select with formatting:

    select to_char(numero, '999999999999999')
      from teste_numerico;

Upshot:

    TO_CHAR(NUMERO,'999999999999999')
    ---------------------------------
      80000000003147                  
      80000000003153                  
      80000000003163                  
      80000000003170                  
      80000000003176                  
      80000000003181                  
      80000000003188                  
      80000000003194                  
      80000000003199                  
      80000000003206                  
      80000000003212                  

     11 linhas selecionadas 

1 answer

0


The numformat

set numformat 99999999999
select *
       from teste_numerico;
  • It worked! Thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.