I'm using PostgreSQL 9.4 and pgAdminIII 1.20 client. When launching an INSERT
on a particular table, I get an error message saying: Details: the key (gid)=(31509) already exists. (SQL State: 23505)
.
I do not enter a gid value in the command in order to let the sequence do the job:
INSERT INTO geo_section (idnum, insee, ident) VALUES (25, '015233', '') ;
The sequence is defined as this:
CREATE SEQUENCE geo_section_gid_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 31509
CACHE 1;
ALTER TABLE geo_section_gid_seq
OWNER TO postgres;
The following query returns 34502
:
SELECT max(gid) FROM geo_section ;
Therefore, I've tried to alter the sequence in order to start sequence from 34503
:
ALTER SEQUENCE geo_section_gid_seq START 34503 ;
I get a success message saying that the query has been executed properly. But the sequence START
parameter remains with 31509
value...