DECIMAL(total,fraction) or NUMERIC(total,fraction) Data
DECIMAL can be an integer or a decimal number.
An integer is a whole number expressed without a decimal number such as -32, 0, or 415.
A decimal number has digits to the right of the decimal point such as -32.4, 0.0, 765.0 or 0.0000627.
In mathematical terms, this number has a precision (total) and a scale (fraction).
The precision (total) is the total or maximum number of digits, both to the right and the left of the decimal point.
The scale (fraction) is the number of digits to the right of the decimal point.
The total can be any number that is 1 or greater. The fraction can be zero or greater and can not exceed the total.
If scale (fraction) is omitted, it defaults to zero.
You can represent a whole number with a fraction of zero, but you really should use INTEGER instead.NUMERIC(total,fraction) is the same as DECIMAL and DEC. In this course, we use DECIMAL.
Example: COL1 DECIMAL(8,2)
COL1 can have any value from -999,999.99 through 0.00 to 999,999.99.
Definition Value
DECIMAL(8) 836
DECIMAL(8,0) 836
DECIMAL(8,1) 835.8
DECIMAL(8,2) 835.75
DECIMAL(8,3) 835.754
DECIMAL(4,1) 835.8
DECIMAL(4,2) This definition is for 2 integers and 2 decimal places.
The value 835.754 exceeds the precision of 2 integers.
The fraction can be truncated. The integer can not be truncated.