Re: duplicate key violates unique constraint

From: vtaquette(at)globo(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: Re: duplicate key violates unique constraint
Date: 2006-09-20 00:10:14
Message-ID: 450D86C3000078BD@mail03.sc2.he.tucows.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Eci Souji 2006-09-20 00:12:39 statistics buffer is full on heavily loaded 8.1.4 db.
Previous Message Tom Lane 2006-09-19 23:05:33 Re: Initializing Datums for use with SPI_execute_plan