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.
| Kind | type |
|---|---|
| Example Language | SQL |
📝 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
- The range -2147483648 to 2147483647 in 4 bytes is exactly the integer type the SERIAL pseudo-type is built on.
- The literal 2147483648 exceeds the INTEGER range, so PostgreSQL treats it as BIGINT; the "integer out of range" error only appears when the value is assigned to an INTEGER column.
- Sequences default to the INTEGER family too, and a sequence can be widened on its own with ALTER SEQUENCE ... AS bigint.
💡 Related Cases
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.