postgresql numeric type without trailing zeros

為{幸葍}努か 提交于 2020-01-25 05:57:08

问题


When use numeric type, for example like this numeric(4,2) and if store in him number 1.2, at end of number are adding zeros for filling scale part right? that is result is 1.20

There is possible to save "short" scale as "short"? that is without adding zeros at end ?


回答1:


You shouldn't worry about extra space used for scale part.

According to documentation values of numeric type saved without trailing zeroes:

Numeric values are physically stored without any extra leading or trailing zeroes. Thus, the declared precision and scale of a column are maximums, not fixed allocations. (In this sense the numeric type is more akin to varchar(n) than to char(n).) The actual storage requirement is two bytes for each group of four decimal digits, plus three to eight bytes overhead.



来源:https://stackoverflow.com/questions/16193321/postgresql-numeric-type-without-trailing-zeros

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!