Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Question about how number scale affects number range

user7425388Aug 15 2024

Could you please tell im if scale for NUMBER type affects number range ?

I thought that according to the Oracle documentation that scale affects only number of digits to the right of the decimal point…

Consider following example:

create table test(
val4 NUMBER(15,4),
val6 NUMBER(15,6)
);

And sample inserts:

insert into test (val4, val6) values (-2222222222, null); --works
insert into test (val4, val6) values (-2222222222, -2222222222); --doesn't work
insert into test (val4, val6) values (2222222222, null); --works
insert into test (val4, val6) values (2222222222, 2222222222); --doesn't work
insert into test (val4, val6) values (1222222222, null); --works
insert into test (val4, val6) values (1122222222, 1122222222); --doesn't work
insert into test (val4, val6) values (null , 1000000000); --doesn't work
insert into test (val4, val6) values (null , 999999999); --works

Colud you please tell me why for some inserts I got following error?

SQL Error: ORA-01438: value larger than specified precision allows for this column
01438. 00000 - "value larger than specified precision allowed for this column"
*Cause: When inserting or updating records, a numeric value was entered
that exceeded the precision defined for the column.
*Action: Enter a value that complies with the numeric column's precision,
or use the MODIFY option with the ALTER TABLE command to expand
the precision.

This post has been answered by Frank Kulash on Aug 15 2024
Jump to Answer
Comments
Post Details
Added on Aug 15 2024
3 comments
383 views