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.
Asked
Active
Viewed 163 times
1 Answers
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)

pathikrit
- 32,469
- 37
- 142
- 221