Corresponding values ​​for -Infinity & Infinity in Postgres

In one case, do we need to pass values ​​for + infinity and -infection to Postgres DB?

What should be the appropriate value to consider.

If not 1, then please suggest the best match.



source to share

2 answers

In fact, you can use the data types +infinity

and -infinity


and FLOAT8

(ie, float

and double precision

) and timestamps.

regress=> SELECT FLOAT8 '+infinity', FLOAT8 '-infinity';
  float8  |  float8   
 Infinity | -Infinity
(1 row)


For other types, either use a separate column, use the min / max values ​​for the type, or (where logically necessary) use null.



add another column name "infinite", 1 means + infinity, -1 means "infinity" when you check numbers, check the column first.

it will save you a lot of time thinking about magic numbers or other things.



All Articles