简体   繁体   English

精度和比例在Oracle NUMBER数据类型中意味着什么

[英]What does precision and scale means in the Oracle NUMBER data type

I have been reading Beginners guide for oracle DB. 我一直在阅读oracle DB的初学者指南。 The definition for precision and scale are quite confusing. 精度和规模的定义非常混乱。 Book says: 书说:

number(6,3) 

Oracle allows for 2 not 6 significant digitalis.

my problem is, 6 means precision. 我的问题是,6意味着精确。 which means number of significant digits. 这意味着有效位数。 so it should accept 6 significant digits. 所以它应该接受6位有效数字。 why does the book says it is 2 significant digits 为什么这本书说这是2位有效数字

The book i am referring to is Oracle Database 11g A Beginner's Guide by McGraw Hill Professional, Dec 18, 2008 , page number 12 我指的是Oracle数据库11g,McGraw Hill Professional的初学者指南,2008年12月18日 ,第12页

Check out the online Oracle doc : 查看在线Oracle 文档

p is the precision, or the maximum number of significant decimal digits, where the most significant digit is the left-most nonzero digit, and the least significant digit is the right-most known digit. p是精确值或有效十进制数的最大数,其中最高有效位是最左边的非零数字,最低有效数字是最右边的已知数字。 Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point. Oracle保证数字的可移植性,精度最高可达20个基数-100位,相当于39或40位十进制数,具体取决于小数点的位置。

s is the scale, or the number of digits from the decimal point to the least significant digit. s是从小数点到最低有效位的小数位数或小数位数。 The scale can range from -84 to 127. 比例范围可以从-84到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 the actual 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 to hundreds. 例如,(10,-2)的规范意味着舍入到数百。

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

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