DECIMAL data type

The DECIMAL data type is a decimal number with precision total digits and with scale digits after the decimal point.

Syntax
DECIMAL [ ( precision [ , scale ] ) ]
Parameters
  • precision   An integer expression between 1 and 127, inclusive, that specifies the number of digits in the expression. The default setting is 30.

  • scale   An integer expression between 0 and 127, inclusive, that specifies the number of digits after the decimal point. The scale value should always be less than, or equal to, the precision value. The default setting is 6.

    The defaults can be changed by setting database options. For information, see precision option [database] and scale option [database].

Remarks

The DECIMAL data type is an exact numeric data type; its accuracy is preserved to the least significant digit after arithmetic operations.

The storage required for a decimal number can be estimated as

2 + int( (before + 1)/2 ) + int( (after + 1)/2 )

The function int takes the integer portion of its argument, and before and after are the number of significant digits before and after the decimal point. The storage is based on the value being stored, not on the maximum precision and scale allowed in the column.

DECIMAL can also be specified as DEC. Regardless of which syntax is used, the data type is described as DECIMAL.

DECIMAL is semantically equivalent to NUMERIC.

See also
Standards and compatibility
  • SQL/2003   Compatible with SQL/2003.