I would think that

1
2
ALTER SEQUENCE sequence_name
      RESTART WITH (SELECT max(id) FROM table_name);

would work, but it doesn’t. Use:


SELECT SETVAL('sequence_name', (SELECT MAX(id) FROM table_name) + 1);

instead and you will be a lot more happier.

blogLater

Mikel

Leave a Reply