How can an Oracle NUMBER have a Scale larger than the Precision?

前端 未结 6 2179
傲寒
傲寒 2021-01-12 17:39

The documentation states: \"Precision can range from 1 to 38. Scale can range from -84 to 127\".

How can the scale be larger than the precision? Shouldn\'t the Scal

6条回答
  •  我在风中等你
    2021-01-12 18:18

    The case where Scale is larger than Precision could be summarized this way:

    Number of digits on the right of decimal point = Scale

    Minimum number of zeroes right of decimal = Scale - Precision

    --this will work 
    select cast(0.123456 as number(5,5)) from dual;
    

    returns 0.12346

    -- but this
    select cast(0.123456 as number(2,5)) from dual;
    --will return "ORA-1438 value too large".  
    --It will not return err with at least 5-2 = 3 zeroes:
    select cast(0.000123456 as number(2,5)) from dual;
    

    returns 0.00012

    -- and of course this will work too
    select cast(0.0000123456 as number(2,5)) from dual;
    

    returning 0.00001

提交回复
热议问题