Oracle 10g 數(shù)據(jù)類型
SQL Server 2005 的數(shù)據(jù)類型
附錄:
1、關(guān)于 NUMBER(p,s) ,能表示的有效值為 1.0 x 10-130 to (but not including) 1.0 x 10126。
p:精度值,指有效位數(shù),從左邊第一個不為0的數(shù)算起,小數(shù)點和負(fù)號不計入有效位數(shù)。取值范圍為 0 ~ 38 。
s:標(biāo)度值,小數(shù)點右邊最小有效數(shù)字位數(shù)。取值范圍為 -84 ~ 127 。
● s>0:精確到小數(shù)點右邊 s 位,并四舍五入。
● s<0:精確到小數(shù)點左邊 s 位,并四舍五入。
例如:
NUMBER(5,3)可以存儲的數(shù)字形式為:pp.sss。
ps.
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 of significant 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.
當(dāng) s > p 時,例如 NUMBER(4,5) ,必須數(shù)值為 0.0xxxx 的數(shù)字(小數(shù)點后 s-p 位加0)。
示例:
定義格式 | 輸入數(shù)值 | 存儲狀態(tài) |
NUMBER | 123.89 | 123.89 |
NUMBER(5) | 123.89 | 124 |
NUMBER(5,0) | 123456 | ORA-01438: 值大于為此列指定的允許精度 |
NUMBER(6,2) | 123.89 | 123.89 |
123.8951 | 123.9 | |
NUMBER(2,5) | 0.000811 | 0.00081 |
123.89 | ORA-01438: 值大于為此列指定的允許精度 | |
1.2e-4 | 0.00012 |