mysql中的nan,Oracle何时/为什么将NaN添加到数据库表中的行

Oracle数据库的数值类型可以存储正负数、零、无穷和非数字(NaN)值。NaN通常出现在浮点或双精度类型中,比如除以零的操作会导致NaN。如果你的应用逻辑或数据出现问题,可能会看到NaN。要避免将数字存储为字符串,因为这不推荐且可能导致问题。检查可能的除以零错误或不正确的数据输入是解决NaN问题的关键。
摘要由CSDN通过智能技术生成

I know that NaN stands for Not a Number. But, I have trouble understanding when and why Oracle adds this to a row.

Is it when it encounters a value less than 0 like a negative number or when its a garbage value.

解决方案

The Oracle Database numeric data types store positive and negative fixed and floating-point numbers, zero, infinity, and values that are the undefined result of an operation—"not a number" or NAN.

As far as I'm aware you can only get NaN in a binary_float or binary_double column; those data types have their own literals for NaN too, and there's an is nan condition for them too, and the nanvl() function to manipulate them.

An example of a way to get such a value is to divide a zero float/double value by zero:

select 0f/0 from dual;

0F/0

----

NaN

... so if you're seeing NaNs your application logic or underlying data might be broken. (Note you can't get this with a 'normal' number type; you get ORA-01476: divisor is equal to zero unless the numerator is float or double).

You won't get NaN for zero or negative numbers though. It's also possible you have a string column and an application is putting the word 'NaN' in, but storing numbers as strings is a bad idea on many levels, so hopefully that is not the case.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值