# How to reset Postgres SERIAL number

> Learn how to reset a Postgres SERIAL sequence back to 1 after deleting rows by running ALTER SEQUENCE tablename_id_seq RESTART, plus a TablePlus shortcut.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-11-08 | Topics: [Database](https://flaviocopes.com/tags/database/) | Canonical: https://flaviocopes.com/how-to-reset-postgres-serial-number/

When testing a table with a `SERIAL` field, this number will grow even if you remove all items in the table (like you’d do during testing), so you might insert a value and its id is `15` for example. 

To restart the sequence from `1`, run the SQL query:

`ALTER SEQUENCE TABLENAME_id_seq RESTART`

Replace `TABLENAME` with your table name, like:

`ALTER SEQUENCE users_id_seq RESTART`

Using TablePlus you have the option to reset the sequence when you truncate a table to remove its content.
