Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I created a table with a SERIAL column but I also manually inserted some rows. I need to update the SERIAL so it goes to the next one.
Let's say your sequence is named $seq. If you used the SERIAL to create the table:
$seq
SERIAL
CREATE TABLE foo {id SERIAL, .... }
the sequence would be called something like foo_id_seq
foo_id_seq
Do this:
SELECT setval('foo_id_seq', (SELECT max(id) FROM foo), TRUE)
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.