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.

Kindtype
Example LanguageSQL

📝 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

More case studies coming soon.

📚 Related Reference

❓ FAQ

QIs the BIGINT ceiling enough?
AFor almost every system, yes: Snowflake-style IDs are far below that ceiling. Only counters that must exceed 9.2×10^18 call for NUMERIC or a custom decimal scheme.
QWhat happens when reading a large integer from JSON?
ANumbers inside json/jsonb come out as text or jsonb values and never become BIGINT automatically. An explicit ::bigint cast is needed to obtain the full integer value without losing precision.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏