1

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.

0

1 Answer 1

1

Let's say your sequence is named $seq. If you used the SERIAL to create the table:

CREATE TABLE foo {id SERIAL, .... }

the sequence would be called something like foo_id_seq

Do this:

SELECT setval('foo_id_seq', (SELECT max(id) FROM foo), TRUE)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.