> This page location: PostgreSQL Data Types > Integer
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL Integer Data Types

**Info:** PostgreSQL's integer types behave the same way wherever you run Postgres, so everything covered here about SMALLINT, INTEGER, and BIGINT applies to any standard Postgres deployment. If you're an enterprise looking for managed Postgres built for the AI era, [Lakebase](https://www.databricks.com/product/lakebase) delivers high performance, strong security, and native integration with the Lakehouse. If you're a developer or startup that needs to ship fast and scale without friction, [Neon](https://neon.com) is the Postgres platform built for you.

**Summary**: this tutorial introduces you to various PostgreSQL integer types including `SMALLINT`, `INTEGER`, and `BIGINT`.

## Introduction to PostgreSQL integer types

![postgresql integer](https://neon.com/postgresqltutorial/postgresql-integer-300x59.png?alignright)
To store the whole numbers in PostgreSQL, you can use one of the following integer types:

- `SMALLINT`
- `INTEGER`
- `BIGINT`

The following table illustrates the specification of each integer type:

| Name       | Storage Size | Min                        | Max                        |
| ---------- | ------------ | -------------------------- | -------------------------- |
| `SMALLINT` | 2 bytes      | -32,768                    | +32,767                    |
| `INTEGER`  | 4 bytes      | -2,147,483,648             | +2,147,483,647             |
| `BIGINT`   | 8 bytes      | -9,223,372,036,854,775,808 | +9,223,372,036,854,775,807 |

If you attempt to store a value outside of the permitted ranges, PostgreSQL will issue an error.

Unlike [MySQL integer](https://www.mysqltutorial.org/mysql-basics/mysql-int/), PostgreSQL does not provide unsigned integer types.

### SMALLINT

The `SMALLINT` requires 2 bytes storage size which can store any integer numbers that are in the range of (-32,767, 32,767).

You can use the `SMALLINT` type for storing something like the ages of people, the number of pages of a book, and so on.

The following statement [creates a table](https://neon.com/postgresql/tutorial/postgresql-create-table) named `books`:

```sql
CREATE TABLE books (
    book_id SERIAL PRIMARY KEY,
    title VARCHAR (255) NOT NULL,
    pages SMALLINT NOT NULL CHECK (pages > 0)
);
```

In this example, the `pages` column is a `SMALLINT` column. Because the number of pages must be positive, we added a [`CHECK`](https://neon.com/postgresql/tutorial/postgresql-check-constraint) constraint to enforce this rule.

### INTEGER

The `INTEGER` is the most common choice between integer types because it offers the best balance between storage size, range, and performance.

The `INTEGER` type requires 4 bytes storage size that can store numbers in the range of (-2,147,483,648, 2,147,483,647).

You can use the `INTEGER` type for a column that stores quite big whole numbers like the population of a city or even country as the following example:

```sql
CREATE TABLE cities (
    city_id serial PRIMARY KEY,
    city_name VARCHAR (255) NOT NULL,
    population INT NOT NULL CHECK (population >= 0)
);
```

Notice that `INT` is the synonym of `INTEGER`.

### BIGINT

If you want to store the whole numbers that are out of the range of the `INTEGER` type, you can use the `BIGINT` type.

The `BIGINT` type requires 8 bytes storage size that can store any number in the range of (-9,223,372,036,854,775,808,+9,223,372,036,854,775,807).

Using `BIGINT` type is not only consuming a lot of storage but also decreasing the performance of the database, therefore, you should have a good reason to use it.

## Summary

- Use `SMALLINT`, `INT`, and `BIGINT` data types to store integers in the database.

---

## Related docs (PostgreSQL Data Types)

- [Boolean](https://neon.com/postgresql/tutorial/boolean)
- [CHAR, VARCHAR, and TEXT](https://neon.com/postgresql/tutorial/char-varchar-text)
- [NUMERIC](https://neon.com/postgresql/tutorial/numeric)
- [DOUBLE PRECISION](https://neon.com/postgresql/tutorial/double-precision-type)
- [REAL](https://neon.com/postgresql/tutorial/real-data-type)
- [SERIAL](https://neon.com/postgresql/tutorial/serial)
- [DATE](https://neon.com/postgresql/tutorial/date)
- [TIMESTAMP](https://neon.com/postgresql/tutorial/timestamp)
- [Interval](https://neon.com/postgresql/tutorial/interval)
- [TIME](https://neon.com/postgresql/tutorial/time)
- [UUID](https://neon.com/postgresql/tutorial/uuid)
- [JSON](https://neon.com/postgresql/tutorial/json)
- [HSTORE](https://neon.com/postgresql/tutorial/hstore)
- [Array](https://neon.com/postgresql/tutorial/array)
- [User-defined Data Types](https://neon.com/postgresql/tutorial/user-defined-data-types)
- [Enum](https://neon.com/postgresql/tutorial/enum)
- [XML](https://neon.com/postgresql/tutorial/xml-data-type)
- [BYTEA](https://neon.com/postgresql/tutorial/bytea-data-type)
- [Composite Types](https://neon.com/postgresql/tutorial/composite-types)
