Postgresql numeric type without trailing zeros

When is a numeric type used, such as this one, numeric(4,2)

and if it stores a number 1.2

then zeros are appended to the end of the number to fill in the part scale

on the right? this is the result1.20

Can the "short" scale be kept as "short"? that is, without adding zeros at the end?

+1


source to share


1 answer


You don't have to worry about the extra space used for the piece scale

.

As per the documentation, values ​​of a numeric type are stored without trailing zeros:



Numeric values ​​are physically stored without any additional indication or trailing zeros. Thus, the declared precision and scale of the column are maxima and not fixed distributions. (In this sense, the numeric type is more akin to varchar (n) than char (n).) The actual storage requirement is two bytes for each group of four decimal digits, plus three to eight bytes.

+4


source







All Articles