Decimal vs. int when using ORM

I use tools ORM / code generators, and I see that they prefer to use the values decimalto intthe comparison with the properties of the column. Is there an advantage to using a decimal number?

The column type in the database is the default value Numberthat is created as Number(38, 0). I suppose.

+4
source share
2 answers

NUMBER NUMBER(38), which has a much larger possible range than int( Int32) (and much more than long). doublehas different rounding semantics, therefore it is decimalpreferable to avoid errors and problems. If ORM can guarantee that data fits inside int, it may be more convenient to use int.

+7
source

Decimal - 128- . Int32 32- , , 32- int. NUMBER (38) INTEGER Oracle, , Decimal, .

, Oracle NUMBER (38), (38 - ), Decimal . , , Int64 , Decimal Oracle NUMBER. 79,228,162,514,264,337,593,543,950,335. "" 29 NUMBER (38).

, NUMBER Oracle. :

NUMBER(9) => Int32
NUMBER(18) => Int64
NUMBER(19+) => Decimal

, . ORM . NUMBER (18) , - .

, - , " " , . OLTP- Decimal Int64, Oracle , NUMBER (1) NUMBER (38), , NUMBER() , VARCHAR, , . , , .

SQL> insert into bbb values(1);

1 row created.

SQL> insert into bbb values(11111111);

1 row created.

SQL> insert into bbb values(1111111111111111111111111);

1 row created.

SQL> select i, vsize(i) from bbb;

         I   VSIZE(I)
---------- ----------
         1          2
  11111111          5
1.1111E+24         14
+1

Source: https://habr.com/ru/post/1542164/


All Articles