Datasheet

18
Chapter 1
Introducing SQL
TABLE 1.3 Precision and Scale Examples
Value Datatype Stored Value Explanation
123.2564 NUMBER 123.2564 The range and precision are set to the
maximum, so the datatype can store any
value.
1234.9876 NUMBER(6,2) 1234.99 Since the scale is only 2, the decimal part
of the value is rounded to two digits.
12345.12345 NUMBER(6,2) Error The range of the integer part is only from
9999 to 9999.
123456 NUMBER(6,2) Error The precision is larger than specified; the
range is only from –9999 to 9999.
1234.9876 NUMBER(6) 1235 The decimal part is rounded to the next
integer.
123456.1 NUMBER(6) 123456 The decimal part is rounded.
12345.345 NUMBER(5,-2) 12300 The negative scale rounds the number
<s> digits left to the decimal point.
–2 rounds to hundreds.
1234567 NUMBER(5,-2) 1234600 Rounded to the nearest hundred.
12345678 NUMBER(5,-2) Error Outside the range; can have only five dig-
its, excluding the two zeros representing
hundreds, for a total of seven digits:
(s – (p) = s + p = 5 + 2 = 7).
123456789 NUMBER(5,-4) 123460000 Rounded to the nearest 10,000.
1234567890 NUMBER(5,-4) Error Outside the range; can have only five
digits, excluding the four trailing zeros.
12345.58 NUMBER(*, 1) 12345.6 The use of
* in the precision specifies the
default limit (38).
0.1 NUMBER(4,5) Error Requires a zero after the decimal point
(5 – 4 = 1).
0.01234567 NUMBER(4,5) 0.01235 Rounded to four digits after the decimal
point and zero.
95127c01.indd 18 2/18/09 6:37:08 AM