INT4 is a shorthand, PostgreSQL-specific alias for the INTEGER data type. It consumes 4 bytes of storage and can hold whole numbers from ‑2,147,483,648 to 2,147,483,647. Because INT4 is just an alias, it has identical performance characteristics, indexing behavior, and semantics as INTEGER or INT in PostgreSQL. Developers often use INT4 in table definitions, CAST expressions, and domain creation to make the chosen size explicit or to match existing codebases that rely on the alias. INT4 is not part of the ANSI SQL standard, so code portability can be affected when moving to engines other than PostgreSQL or its derivatives. Use INT4 (or INTEGER) for columns that do not need values outside the 32-bit signed range. For larger ranges use BIGINT (INT8); for smaller ranges use SMALLINT (INT2). Serial variants: SERIAL4 or INT4 GENERATED ALWAYS AS IDENTITY create auto-incrementing 4-byte integer columns. These share the same range as INT4 but automatically populate sequential values. Caveats: • Overflow raises an error. • INT4 stores only whole numbers; decimals are truncated if implicitly cast. • Cross-database migration requires mapping INT4 to INTEGER or INT.
INTEGER, INT, BIGINT (INT8), SMALLINT (INT2), SERIAL, SERIAL4, IDENTITY columns, NUMERIC
PostgreSQL 7.0
INT4 can store any whole number between ‑2,147,483,648 and 2,147,483,647.
INT4 is PostgreSQL-specific. On other systems you should replace it with INTEGER or INT to maintain compatibility.
Yes. INT4 uses 4 bytes per value, while BIGINT uses 8 bytes. Choosing the smallest adequate type improves cache efficiency and I/O throughput.
Declare the column as SERIAL4 or INT4 GENERATED ALWAYS AS IDENTITY; PostgreSQL will manage a sequence and populate new values automatically.