Why doesn't this rule prevent duplicate key violations?
(postgresql) I was trying to COPY csv data into a table but I was getting duplicate key violation errors, and there's no way to tell COPY to ignore those, so following internet wisdom I tried adding this rule: CREATE OR REPLACE RULE ignore_duplicate_inserts AS ON INSERT TO mytable WHERE (EXISTS ( SELECT mytable.id FROM mytable WHERE mytable.id = new.id)) DO NOTHING; to circumvent the problem, but I still get those errors - any ideas why ? Rules by default add things to the current action : Roughly speaking, a rule causes additional commands to be executed when a given command on a given table