postgres update sequence to max value code example Example: postgres set sequence value to max id SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));