postgres: ERROR: duplicate key violates unique constraint

Problem może wystąpić np. przy przeniesieniu bazy z mysql do postgresa.

$ psql

baza=> \ds


List of relations
Name | Type | Owner
tfile_id__seq | sequence | wrobelm
tgroup_id__seq | sequence | wrobelm
tprog_id__seq | sequence | wrobelm
tuser_id__seq | sequence | wrobelm

i teraz dla każdej pary sekwencja – tabela robimy:

baza=> select max(id_) from tuser;
(1 row)
baza=> select setval(‘tuser_id__seq’,82);
(1 row)

itd. itd.

This entry was posted in PostgreSQL. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">