This command for only change auto generated key sequence value in postgresql
ALTER SEQUENCE "your_sequence_name" RESTART WITH 0;
In place of zero you can put any number from which you want to restart sequence.
default sequence name will "TableName_FieldName_seq"
. For example, if your table name is "MyTable"
and your field name is "MyID"
, then your sequence name will be "MyTable_MyID_seq"
.
This is answer is same as @murugesanponappan's answer, but there is a syntax error in his solution. you can not use sub query (select max()...)
in alter
command. So that either you have to use fixed numeric value or you need to use a variable in place of sub query.