I have a primery key in my table as follows:
CREATE TABLE a (
id serial NOT NULL,
valuea citext NOT NULL,
CONSTRAINT a_pkey PRIMARY KEY (id),
);
Table had the following rows:
id value
198 b
199 j
By accident I did this insert
Insert Into a(id,valuea) values (200,'hello');
Now, when I try to do another insert in the correct way:
Insert Into a(valuea) values ('b');
I expect it to insert (201,b) but the serial counter doesn't know 200 has been used because of the last manual insert.
I get:
ERROR: duplicate key value violates unique constraint "a_pkey" DETAIL: Key (id)=(200) already exists.
I understand this error.. basically it happens because my last insert was not used the Serial and therefore it's counter didn't rise up.
What I don't know is how to fix it?
How do I tell the serial counter to start from 201?