NUMBER Data Type

本文详细解释了Oracle NUMBER 数据类型的特性,包括它如何存储从1.0x10^-130到但不包括1.0x10^126的正数和负数固定数值,以及如何使用其形式和参数(精度和刻度)来定义和操作这些数值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The<wbr><code style="font-family:monospace; font-size:12px">NUMBER</code><wbr>data type stores zero as well as<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:19px"><strong>positive(肯定的,确定的,正数)</strong></span>and negative(负数,负的) fixed numbers with<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:19px"><strong>absolute values(绝对值)</strong></span><wbr>from 1.0 x 10<sup>-130</sup><wbr>to but not including 1.0 x 10<sup>126</sup>. If you specify an<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:19px"><strong>arithmetic(算术)</strong></span><wbr><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:19px"><strong>expression_r(表达,表达式)</strong></span>whose value has an absolute value greater(大于) than or equal to 1.0 x 10<sup>126</sup>, then Oracle returns an error. Each<wbr><code style="font-family:monospace; font-size:12px">NUMBER</code><wbr>value<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:19px"><strong>requires(需要)</strong></span>from 1 to 22 bytes.</wbr></wbr></wbr></wbr></wbr></wbr></wbr>

Specify a fixed-point number using thefollowing form(以下形式):

NUMBER(p,s)

where(其中):

  • p<wbr>is the<wbr><span style="word-wrap:normal; word-break:normal; line-height:21px; font-weight:bold"><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">precision(精度)</span></span>, or the maximum number of<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>significant(重大的,有效的)</strong></span><strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">decimal digits(小数位数)</span></strong>, where the<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>most(大部分的)</strong></span>significant digit is the left-most<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">nonzero digit(非零的数字)</span></strong>, and the<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">least(最</span></strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>小的,最少的)</strong></span>significant digit is the right-most<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>known digit(已知位数)</strong></span>. Oracle<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>guarantees(保证)</strong></span>the<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">portability(轻便,可移植性的)</span></strong>of numbers with precision of up to 20 base-100 digits,<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">which(这是)</span></strong>is<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>equivalent to(相当于,等价于)</strong></span>39 or 40 decimal digits depending on the<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>position(位置)</strong></span>of the<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">decimal point(小数点)</span></strong>.</wbr></wbr>

  • s<wbr>is the<wbr><span style="word-wrap:normal; word-break:normal; line-height:21px; font-weight:bold"><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">scale(刻度,比例,规模)</span></span>, or the number of digits from the decimal point to the least significant digit. The scale can<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>range(范围,幅度)</strong></span>from -84 to 127.</wbr></wbr>

    • 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 theleft side(左侧)of the decimal point, because theactual data(实际数据)isrounded to(四舍五入到)the specified number of places to the left of the decimal point. For example, aspecification(规格,规范)of (10,-2) means toround(圆)to hundreds.

Scale can be(能够,可以)<wbr><strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">greater(大于)</span></strong>than precision, most<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>commonly</strong></span><strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">(最常用的)</span></strong>when<wbr><code style="font-family:monospace; font-size:12px">e</code><wbr><strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">notation(注释,标记)</span></strong>is used. When scale is greater than precision, the precision specifies the maximum number of significant digits to the right of the decimal point. For example, a column<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>defined(定义)</strong></span>as<wbr><code style="font-family:monospace; font-size:12px">NUMBER(4,5)</code><wbr>requires a zero for the first digit after the decimal point and rounds all values<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">past(过去,往事)</span></strong>the fifth digit after the decimal point.</wbr></wbr></wbr></wbr></wbr>

It is good practice(好做法)<wbr>to specify the scale and precision of a fixed-point number column for<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">extra(额外)</span></strong>integrity<span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px"><strong>(完整)</strong></span><wbr>checking on<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">(检查,核实)</span></strong>input. Specifying scale and precision does not force all values to a fixed length. If a value<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">exceeds(超过)</span></strong>the precision, then Oracle returns an error. If a value exceeds the scale, then Oracle<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">rounds it(四舍五入)</span></strong>.</wbr></wbr>

Specify aninteger(整数)using the following form:

NUMBER(p)

Thisrepresents(代表)a fixed-point number with precision<wbr><code style="font-family:monospace; font-size:12px"><span style="word-wrap:normal; word-break:normal; line-height:18px; font-style:italic">p</span></code><wbr>and scale 0 and is<strong><span style="color:#ED1C24; word-wrap:normal; word-break:normal; line-height:21px">equivalent to(相当于)</span></strong><wbr><code style="font-family:monospace; font-size:12px">NUMBER(p,0)</code>.</wbr></wbr></wbr>

Specify afloating-point number(浮点数)using the following form:

NUMBER

The absence(没有) of precision and scale designators(指定这,标志符) specifies the maximum range and precision for an Oracle number.

See Also(另见):

"Floating-Point Numbers"

Table 3-2<wbr>show how Oracle stores data using different precisions and scales.</wbr>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值