How to reset a sequence number in Postgres

To reset a sequence number in Postgres do the following:
SELECT setval('sequence_name', 1, false);

The "false" argument means that the next value of the sequence will be 1

By default sequences start from 1, to make a sequence start from 0 you will need to do the following when creating the sequence:

CREATE SEQUENCE sequence_name MINVALUE 0;

Last updated: 13/07/2006