From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Nafees Sardar" <nafees(at)epazz(dot)net> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Duplicate key value violates unique constraint |
Date: | 2020-03-16 16:27:09 |
Message-ID: | 7798.1584376029@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"Nafees Sardar" <nafees(at)epazz(dot)net> writes:
> I migrate my data from MS Sql server to postgreSQL database, now when I try
> to insert new row it gives me error "duplicate key value violates unique
> constraint". For example I have a table which contains 100 rows of records
> when I go for inserting 101 row it give duplicate value constraint error.
> When I pass PK value manually its working, and one more thing auto increment
> is enabled for all tables .
Sounds like you need to adjust the sequence counters underlying the
auto-increment columns so that their settings are higher than any
of the already-existing ID values. Auto-increment isn't really a
native concept in Postgres, it's something you have to build from
a sequence object and a suitable default expression. Getting the
sequence set correctly is an easy step to miss when migrating from
a different DBMS.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2020-03-16 20:48:22 | BUG #16304: ECPG won't accept input from STDIN |
Previous Message | David G. Johnston | 2020-03-16 16:23:44 | Re: Duplicate key value violates unique constraint |