postgresq how to reset counter for auto increment code example
Example 1: postgresql reset auto_increment index
-- Change the starting value of the sequence
ALTER SEQUENCE project_id_seq RESTART 3000;
-- Same but dynamic :
SELECT SETVAL('project_id_seq', (SELECT MAX(id) + 1 FROM project));
Example 2: postgresql update auto_increment value
ALTER SEQUENCE product_id_seq RESTART WITH 1453