Reset sequence value as 1
First set the minimum value of the sequence
alter sequence mytable_id_seq minvalue 0 start with 1;
Now either reset it:
SELECT setval('mytable_id_seq', 0)
Or reset it while truncating:
truncate mytable restart identity;
Either use the third argument for setval()
:
setval(yourseq, 1, false)
http://www.postgresql.org/docs/current/static/functions-sequence.html
Or alter the sequence:
alter sequence yourseq restart
http://www.postgresql.org/docs/current/static/sql-altersequence.html