Resetting PostgreSQL Sequence
Published on February 21, 2015 by Bo Andersen
Okay folks, this is going to be a short one! Sometimes you may want to reset a PostgreSQL sequence, for instance after removing data from a tabel. You can do this very easily by executing the following statement:
ALTER SEQUENCE company_id_seq RESTART WITH 1;
company_id_seq is the name of the sequence that you want to reset, and 1 is the value that you want the sequence to start at.
That is all there is to it. Happy coding!