Postgres实际轮到小数点后4位

时间:2018-03-16 09:45:50

标签: postgresql types precision

我的Postgres表格中有latitude类型的列real

在Postico中查看它,其值为57.70887。 但是从psql或代码中选择它,返回的值将四舍五入到小数点后4位:

# SELECT latitude from categories where id = 4;

 latitude
----------
  57.7089
(1 row)

我做错了什么?

Postgres 9.6。

1 个答案:

答案 0 :(得分:0)

如果您关心精确度,则列不应为real。浮点类型仅存储近似值。请改用numeric来保留与插入完全相同的值。

考虑: