Re: duplicate key violates unique constraint - Mailing list pgsql-general

From vtaquette@globo.com
Subject Re: duplicate key violates unique constraint
Date
Msg-id 450D86C3000078BD@mail03.sc2.he.tucows.com
Whole thread Raw
In response to duplicate key violates unique constraint  (vtaquette@globo.com)
List pgsql-general
Hey, I've just find out what's happening.
The problem is the "serial" datatype creates a sequence in the background
(project_id_seq). If the sequence current numeber is 1, and I manually insert
a new entry whit ID=2, the sequence doesn't "know" it. So when I try the
INSERT statement, the next value in sequence is 2, and I get the error.
The thing is, I'm migrating my system from mysql to postgresql, and that's
why I was inserting directely the numbers (importing the .sql file), without
respecting the backgroud sequence.

Thanks a lot for those who answered me.
Regards,
Verônica



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Initializing Datums for use with SPI_execute_plan
Next
From: Eci Souji
Date:
Subject: statistics buffer is full on heavily loaded 8.1.4 db.