# Integer types
Express signed integers

> For the complete documentation index, see [llms.txt](https://preview.materialize.com/materialize/40269/llms.txt).


## `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](https://preview.materialize.com/materialize/40269/markdown-docs/sql/functions/cast/index.md).

#### 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`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/boolean/index.md) (`integer` only) | Explicit
[`numeric`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/numeric/index.md) | Implicit
[`oid`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/oid/index.md) | Implicit
[`real`/`double precision`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/float/index.md) | Implicit
[`text`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/text/index.md) | Assignment
[`uint2`/`uint4`/`uint8`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/uint/index.md) | Depends on specific cast

#### To `integer` or `bigint`

You can cast the following types to integer types:

From | Required context
---|--------
[`boolean`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/boolean/index.md) (`integer` only) | Explicit
[`jsonb`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/jsonb/index.md) | Explicit
[`oid`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/oid/index.md) (`integer` and `bigint` only) | Assignment
[`numeric`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/numeric/index.md) | Assignment
[`real`/`double precision`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/float/index.md) | Assignment
[`text`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/text/index.md) | Explicit
[`uint2`/`uint4`/`uint8`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/types/uint/index.md) | Depends on specific cast

## Examples

```mzsql
SELECT 123::integer AS int_v;
```
```nofmt
 int_v
-------
   123
```

<hr/>

```mzsql
SELECT 1.23::integer AS int_v;
```
```nofmt
 int_v
-------
     1
```
