Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

float or double precision

When I tell postgreSQL to show a column as float, I always get as a result "double precision".

Is it the same?

like image 996
Da Da N Avatar asked Mar 23 '26 08:03

Da Da N


1 Answers

Like Damien quoted from the documentation:

PostgreSQL also supports the SQL-standard notations float and float(p) for specifying inexact numeric types. Here, p specifies the minimum acceptable precision in binary digits.
PostgreSQL accepts float(1) to float(24) as selecting the real type, while float(25) to float(53) select double precision.
Values of p outside the allowed range draw an error.
float with no precision specified is taken to mean double precision.

PostgreSQL, like other databases, supports the SQL standard by supplying an appropriate data type when a certain SQL standard type is requested. Since real or double precision fit the bill here, they are taken instead of creating new redundant types.

The disadvantage is that the data type of a column may read different from what you requested, but as long as it handles your data the way it should, is that a problem?

like image 87
Laurenz Albe Avatar answered Mar 24 '26 20:03

Laurenz Albe