Numbers
Interact with sample code to understand the limits of the data types for numbers in PostgreSQL.
We'll cover the following...
PostgreSQL implements multiple data types to handle numbers, as seen in the documentation chapter about numeric types. Please look at the table given below:
Numeric data types in PostgreSQL
Name | Description |
| 32-bit signed numbers |
| 64-bit signed numbers |
| 16-bit signed numbers |
| arbitrary precision numbers |
| 32-bit floating-point numbers with 6 decimal digits precision |
| 64-bit floating-point numbers with 15 decimal digits precision |
The SQL query system is statically typed. PostgreSQL must determine the data type of each column input in the query and result set before planning and implementation. For numbers, it means that the type of every number literal must be derived at query parsing time.
The data type of literals
In the following query, we count how many times a driver won a race when they started in the pole position per season and return the ten drivers who have done that the most in all the records or Formula 1 results. The query uses integer expressions grid = 1
and position = 1
, and PostgreSQL is left to figure out which ...