NUMBER Data Type

The NUMBER data type stores zero as well as positive正数 and negative负数 fixed numbers withabsolute values绝对值 from 1.0 x 10-130 to but not including 1.0 x 10126. If you specify指定 anarithmetic expression算术表达式 whose value has an absolute value greater较大 than or equal to 1.0 x 10126, then Oracle returns an error. Each每个 NUMBER value requires需要 from 1 to 22 bytes.

Specify指定 a fixed-point number using the following form:

NUMBER(p,s)

where:

  • p is the precision精度, or the maximum number of significant decimal digits有效小数位数, where the most significant digit有效位 is the left-most nonzero digit非零位, andthe least significant digit最低有效位 is the right-most known digit数字. Oracleguarantees保证 the portability of可移植性 numbers with precision精度 of up to 20 base-100 digits, which is equivalent相等的 to 39 or 40 decimal小数 digits depending on theposition of位置 the decimal point.

  • s is the scale标度, or the number of digits from the decimal point to the least significant digit. The scale标度can range from -84 to 127.

    • Positive正数 scale is the number of significant digits有效位 to the right of the decimal point to and including the least significant digit.

    • Negative负数 scale is the number of significant digits to the left of the decimal小数point, to but not including the least significant digit. For negative负数 scale the least significant digit is on the left side左边 of the decimal point, because theactual实际 data is rounded全面 to the specified指定 number of places to the left of the decimal point. For example, a specification规格 of (10,-2) means to round tohundreds百位.

Scale标度 can be greater than precision精度, most commonly通常 when e notation注释 is used. When scale is greater than precision, the precision specifies指定 the maximum number ofsignificant digits有效位 to the right of the decimal point. For example, a column defined定义as NUMBER(4,5) requires需要 a zero for the first digit数字 after the decimal point and rounds all values past the fifth digit过五位数 after the decimal point.

It is good practice练习 to specify指定 the scale and precision精度 of a fixed-point number column for extra integrity额外的完整性 checking on input. Specifying指定 scale and precision does not force all values to a fixed length. If a value exceeds the precision, then Oracle returns an error. If a value exceeds超过 the scale, then Oracle rounds it.

Specify指定 an integer整数 using the following form:

NUMBER(p)

This represents代表 a fixed-point number with precision p and scale 0 and is equivalent相等的to NUMBER(p,0).

Specify指定 a floating-point number using the following form:

NUMBER

The absence没有 of precision and scale designators specifies指定 the maximum range and precision for an Oracle number.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值