简体   繁体   English

Oracle 中的数字格式问题

[英]Number format issue in Oracle

So i have created a test table having a number column which is of the data type Number(11,8) .所以我创建了一个测试表,它有一个数字列,它的数据类型为Number(11,8) Now when i am trying to insert the value 13332 in the table it is throwing an oracle error saying:现在,当我尝试在表中插入值13332时,它抛出一个 oracle 错误说:

ORA-01438: value larger than specified precision allowed for this column ORA-01438: 值大于此列允许的指定精度

I am not sure why.我不知道为什么。 The same works when i am inserting into a column with data type Number(12,6)当我插入数据类型为 Number(12,6) 的列时,同样有效

INSERT INTO MY_TABLE(COLUMN_1)
values('13332');

The reason is - out of 11 digits you have specified 8 digits after decimal places so for the whole number part (before the decimal) you are allowed only 3 digits.原因是 - 在 11 位数字中,您指定了小数点后 8 位数字,因此对于整数部分(小数点前),您只允许使用 3 位数字。

Assuming you want to reserve 8 digits post decimal place in your case it would work if you define the data type as number(13,5) which would allow 5 digits for the whole number.假设您想在您的情况下保留 8 位后小数位,如果您将数据类型定义为 number(13,5) 这将允许整个数字的 5 位数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM