# SQL - Decimal(p,s) or Numeric(p,s)

DECIMAL and NUMERIC are sql datatype used to represent a fixed point notation (exact number)

numeric is generally functionally identical to decimal.

## Example

With a DECIMAL(5,2):

• the number has:
• a precision of 5
• and a scale of 2
• you would be able to store any value with:
• values can be stored in the range from -999.99 to 999.99.

The number 00123456.780 has:

• a precision of 8 (ie 12345678)
• and a scale of 2 (ie 78)

## Syntax

NUMERIC(p, s)
DECIMAL(p, s)


where:

## Numeric vs Decimal

The Sql standard defined NUMERIC and DECIMAL in the following words:

• NUMERIC specifies the data type exact numeric, with the decimal precision and scale specified by the <precision> and <scale>.
• DECIMAL specifies the data type exact numeric, with the decimal scale specified by the <scale> and the implementation-defined decimal precision equal to or greater than the value of the specified <precision>.

## Storage and range

Maximum storage sizes vary, based on the precision.

Precision Storage bytes
1 - 9 5
10-19 9
20-28 13
29-38 17

For a precision of 38, the range of value is $-10^{38 +1}$ through $10^{38}$