Postgres manually alter sequence

database-sequence, ddl, postgresql, sql

Solution

The parentheses are misplaced:

SELECT setval('payments_id_seq', 21, true);  -- next value will be 22

Otherwise you're calling `setval` with a single argument, while it requires two or three.

This is the same as `SELECT setval('payments_id_seq', 21)`

Problem

I'm trying to set a sequence to a specific value. ``` SELECT setval('payments_id_seq'), 21, true; ``` This gives an error: `ERROR: function setval(unknown) does not exist` Using `ALTER SEQUENCE` doesn't seem to work either? ``` ALTER SEQUENCE payments_id_seq LASTVALUE 22; ``` How can this be done? Ref: https://www.postgresql.org/docs/current/functions-sequence.html

Original source

Related problems