Reset or change auto increment in postgres using ALTER SEQUENCE
command. To use that command you can determine which table and column that you wil change.
For example you have roles
table and inside that role
table you want reset the id
column.
You can use this simple query below to reset auto increment in postgres.
ALTER SEQUENCE roles_id_seq RESTART WITH 1
note:
the _seq
is required, you cannot remove it. So the pattern is {table}_{column}_seq
.
In postgres you cannot change to 0, the minimum value is 1.