These examples show how Oracle stores data using different precisions and scales.
Actual Data Specified as Stored as
----------- ------------ ---------
7456123.89 NUMBER 7456123.89
7456123.89 NUMBER (9) 7456124
7456123.89 NUMBER (9,2) 7456123.89
7456123.89 NUMBER (9,1) 7456123.9
7456123.8 NUMBER (6) exceeds precision
7456123.8 NUMBER (15,1) 7456123.8
7456123.89 NUMBER (7,-2) 7456100
7456123.89 NUMBER(7,2) exceeds precision
--------------
The following examples show the effects of a scale greater than precision:
Actual Data Specified as Stored as
----------- ------------ ---------
.01234 NUMBER(4,5) .01234
.00012 NUMBER(4,5) .00012
.000127 NUMBER(4,5) .00013
.0000012 NUMBER(2,7) .0000012
.00000123 NUMBER(2,7) .0000012
Main Topics
Browse All Topics





by: sonicefuPosted on 2008-08-26 at 02:02:17ID: 22312714
NUMBER DATATYPE
--
---------- -------
-------------------------
The NUMBER datatype is used to store zero, positive and negative
fixed and floating point numbers with magnitudes between 1.0 x
10
digits of precision. If you specify an arithmetic expression whose
value has a magnitude greater than or equal to 1.0 x 10
returns an error. You can specify a fixed point number datatype
with this syntax:
NUMBER(p,s)
-----------------
where:
p
is the precision, or the total number of digits. Oracle guarantees
the portability of numbers with precision ranging from 1 to 38.
s
is the scale, or the number of digits to the right of the decimal
point. The scale can range from -84 to 127.
=============> You can also use one of these alternate forms:
NUMBER(p)
is a fixed point number with precision p and scale 0.
NUMBER
is a floating point number with precision 38. Note that a scale
value is not applicable for floating point numbers.
SCALE AND PRECISION
--------------------------
Specify the scale and precision of a 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, Oracle returns an error. If a value exceeds the scale,
Oracle rounds it.
NEGATIVE SCALE
----------------------
If the scale is negative, 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.
SCALE GREATER THAN PRECISION
--------------------------
You can specify a scale that is greater than precision, although it
is uncommon. In this case, the precision specifies the maximum
number of digits to the right of the decimal point. As with all
number datatypes, if the value exceeds the precision, Oracle returns
an error. If the value exceeds the scale, Oracle rounds the value.
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.