Hi,
From Oracle Docs
"The absence of precision and scale designators specifies the maximum range and precision for an Oracle number."
https://docs.oracle.com/database/121/SQLRF/sql_elements001.htm#SQLRF30020 When i declared number with out precision i am able to enter digits more than 38 but not when i give precision range is 38. for 38 i get error, why it works like that.
I did this scenario in Live SQl and shared the link.
Thanks.
The scale defaults to zero. So when you declare a number(38), you're really specifying a number(38,0). That is one with 38 digits of precision and no scale. So the largest number you can store is the digit 9, 38 times.
Whereas a number with no scale or precision allows the maximum values for both. So you can store any number in the range from 1.0 x 10E-130 to but not including 1.0 x 10E126
The database rounds numbers that exceed the scale. So if you assign a value with more digits of precision, the database can change the number of significant figures.
So if you assign a 50 digit value to a number, the database will round it:
declare
num number;
begin
num := 12345678901234567890123456789012345678901234567890;
dbms_output.put_line( length(num) || '-'|| num);
end;
/
50-12345678901234567890123456789012345678900000000000
But this won't work with a number(38), because you've explicitly limited the range of values to 0 .. 99,999,999,999,999,999,999,999,999,999,999,999,999