0

How could one create a constraint to avoid duplicate values beeing entered in the database but simply ignoring them and not stoping a COPY command from ending. I tried code below adding a UNIQUE constraint but this way it stops a possible BULK copy when it founds a duplicate , i simply want to ignore and move on .

ALTER TABLE postal_code
  ADD CONSTRAINT unique_postalcode_geom UNIQUE(postal_code, geom);
Jorge Vidinha
  • 404
  • 7
  • 20
  • This question has come up already. Instead of on duplicate update, it would be on duplicate do nothing. See [Insert, on duplicate update in PostgreSQL?](http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/6527838#6527838) or [How do I do an UPSERT (MERGE, INSERT … ON DUPLICATE UPDATE) in PostgreSQL?](http://stackoverflow.com/questions/17267417/how-do-i-do-an-upsert-merge-insert-on-duplicate-update-in-postgresql/17267423#17267423) – conspicillatus Nov 11 '15 at 14:28
  • You can't do this with a trigger, not using `COPY`. – Craig Ringer Nov 12 '15 at 04:57

0 Answers0