BIGINT (8-byte integer)
Last updated: 2026-11-04
BIGINT (8-byte integer)
BIGINT (INT8) occupies 8 bytes with a range of -9223372036854775808 to 9223372036854775807, making it the largest built-in integer type in PostgreSQL. It becomes mandatory when primary keys come from Snowflake-style algorithms, distributed ID services or the BIGSERIAL pseudo-type. The ceiling is still finite, and double-precision floats only represent integers exactly up to 2^53, so mixing the two silently loses precision.
| Kind | type |
|---|---|
| Example Language | SQL |
📝 Syntax
BIGINT | INT8 —— range -9223372036854775808 to 9223372036854775807, 8 bytes
Returns:Holds an 8-byte signed integer. Multiplication with NUMERIC switches to NUMERIC, while multiplication with DOUBLE PRECISION yields DOUBLE PRECISION and may lose precision above 2^53.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
id | counter | col_type
----+----------------------+----------
1 | 9007199254740993 | bigint
2 | -9223372036854775808 | bigint
📌 Key Points
- 9007199254740993 is 2^53+1, a value double-precision floats cannot represent exactly, which is why IDs must not be stored as floats.
- The BIGSERIAL pseudo-type is equivalent to BIGINT plus an auto-increment sequence, and is the usual choice for growing large tables.
- Reading a number out of JSON with ->> yields text; an explicit ::bigint cast is needed to get a BIGINT value.