오승현
오승현

Reputation: 1

Why does the range of datatype number in oracle database is 38?

I read oracle docs that the range of datatype "number" in database is 38, and that is maximum range.

I google it and cant find anything except 38 is laws of karma, guardian angels...

Would you mind explaining why the range of number is 38?

Thanks!

Upvotes: 0

Views: 147

Answers (1)

Littlefoot
Littlefoot

Reputation: 142968

It is precision (not related to karma nor angels :)).

Documentation says that number's format is NUMBER [ (p [, s]) ] :

Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127. Both precision and scale are in decimal digits. A NUMBER value requires from 1 to 22 bytes.

Precision is number of digits in a number. For example, number 123.45 has 5 digits so its precision is 5.

Scale is number of digits to the right of decimal point; in this example, it is 45 which makes 2 digits so scale is 2.

It means that (if we suppose that numbers will look like that) table you'd create would look as

create table (some_value   NUMBER (5, 2));   --> precision 5, scale 2

If you violate precision, Oracle will raise an error. You can, on the other hand, violate scale - in that case, Oracle will round that value.

Upvotes: 1

Related Questions