• 使用默认精度
create table test(id double precision);

insert into test values (1.1234567890123456789);
insert into test values (1.1234567890012345678);
insert into test values (1.1234567890012545678);
insert into test values (10.1234567890012545678);
insert into test values (123.012345678901234567);
select * from test;
id
------------------
1.12345678901235
1.12345678900123
1.12345678900125
10.1234567890013
123.012345678901
1.12345678901235
1.12345678900123
1.12345678900125
10.1234567890013
123.012345678901
(10 rows)
  • 修改默认精度
postgres=# show extra_float_digits ;
extra_float_digits
--------------------
1
(1 row)

postgres=# set extra_float_digits to 3;
SET
postgres=#

postgres=# show extra_float_digits ;
extra_float_digits
--------------------
3
(1 row)

postgres=# select id from test SF;
id
---------------------
1.12345678901234569
1.12345678900123458
1.12345678900125456
10.1234567890012546
123.012345678901241
1.12345678901234569
1.12345678900123458
1.12345678900125456
10.1234567890012546
123.012345678901241