INTEGER (4-byte integer)

Last updated: 2026-11-04

INTEGER (4-byte integer)

INTEGER (also spelled INT4) is the workhorse integer type in PostgreSQL: 4 bytes, ranging from -2147483648 to 2147483647. It is the default choice for counters, amounts stored in minor units and status codes in ordinary business tables, costing only 2 bytes more than SMALLINT while covering virtually every real workload. Writing INTEGER or INT4 in DDL is exactly equivalent.

Kindtype
Example LanguageSQL

📝 Syntax

INTEGER  |  INT  |  INT4  ——  range -2147483648 to 2147483647, 4 bytes

Returns:Holds a 4-byte signed integer. An integer literal outside the INTEGER range is automatically promoted to BIGINT or NUMERIC rather than raising an error.

▶ 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 |    qty     | col_type
----+------------+----------
  1 |        100 | integer
  2 | 2147483647 | integer

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QWhat is the INT4 spelling?
AINT4 is the internal type name of INTEGER, a legacy spelling inherited from PostgreSQL's built-in type OIDs. pg_typeof returns 'integer' and information_schema reports 'integer'; both refer to the same type.
QShould money use INTEGER or NUMERIC?
AStoring minor units (cents) as INTEGER is fastest and free of rounding, but every participant must follow the same convention. Storing major units directly as NUMERIC is more readable. Never store money in a floating-point type.
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%

🙏 帮我们做得更好

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

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