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

左心房为你撑大大i 提交于 2019-12-12 10:52:49

问题


I have been reading Beginners guide for 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. which means number of significant digits. so it should accept 6 significant digits. why does the book says it is 2 significant digits

The book i am referring to is Oracle Database 11g A Beginner's Guide by McGraw Hill Professional, Dec 18, 2008, page number 12


回答1:


Check out the online Oracle doc:

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. 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.

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 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.



来源:https://stackoverflow.com/questions/10661708/what-does-precision-and-scale-means-in-the-oracle-number-data-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!