Home > front end >  Oracle Buildin Datatypes : Number
Oracle Buildin Datatypes : Number

Time:07-05

What is the evaluation of a of value 123.89 in decemial storage in Oracle Databa for NUMBER(3) when there is no scale is defined step by step?

CodePudding user response:

I don't know what Oracle does step-by-step, but - in the end, it rounds the value:

SQL> create table test (col number(3));

Table created.

SQL> insert into test values (123.89);

1 row created.

SQL> insert into test values (200.13);

1 row created.

SQL> select * from test;

       COL
----------
       124
       200

SQL>

Why? Because numbers can have precision and scale. number(3) means that there's no scale (i.e. is equal to number(3, 0)) so - if there's no scale and value you enter exceeds it, then Oracle rounds it.

Read more about NUMBER datatype in documentation.

  • Related