Right from the manual:
The types
decimal
andnumeric
are equivalent. Both types are part of the SQL standard.
As for the “why do I need to use it”, this is also explained in the manual:
The type numeric can store numbers with a very large number of digits and perform calculations exactly
(Emphasis mine).
If you need numbers with decimals, use decimal
(or numeric
) if you need numbers without decimals, use integer
or bigint
. A typical use of decimal
as a column type would be a “product price” column or an “interest rate”. A typical use of an integer type would be e.g. a column that stores how many products were ordered (assuming you can’t order “half” a product).
double
and real
are also types that can store decimal values, but they are approximate types. This means you don’t necessarily retrieve the value you stored. For details please see: http://floating-point-gui.de/