I need that after TRUNCATE table, reset his sequence, for this I do :
TRUNCATE
SELECT setval(\'mytable_id_seq\', 1)
After, when insert
Either use the third argument for setval():
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