Materialize Documentation
s
Join the Community github/materialize

Integer types

smallint info

Detail Info
Size 2 bytes
Aliases int2
Catalog name pg_catalog.int2
OID 23
Range [-32,768, 32,767]

integer info

Detail Info
Size 4 bytes
Aliases int, int4
Catalog name pg_catalog.int4
OID 23
Range [-2,147,483,648, 2,147,483,647]

bigint info

Detail Info
Size 8 bytes
Aliases int8
Catalog name pg_catalog.int8
OID 20
Range [-9,223,372,036,854,775,808, 9,223,372,036,854,775,807]

Details

Valid casts

For details about casting, including contexts, see Functions: Cast.

Between integer types

From To Required context
smallint integer Implicit
smallint bigint Implicit
integer smallint Assignment
integer bigint Implicit
bigint smallint Assignment
bigint integer Assignment

From integer types

You can cast integer types to:

To Required context
boolean (integer only) Explicit
numeric Implicit
oid Implicit
real/double precision Implicit
text Assignment

To integer or bigint

You can cast the following types to integer types:

From Required context
boolean (integer only) Explicit
jsonb Explicit
oid (integer and bigint only) Assignment
numeric Assignment
real/double precision Assignment
text Explicit

Examples

SELECT 123::integer AS int_v;
 int_v
-------
   123

SELECT 1.23::integer AS int_v;
 int_v
-------
     1
Did this info help?
Yes No