postgresql: \copy method enter valid entries and discard exceptions
问题 When entering the following command: \copy mmcompany from '<path>/mmcompany.txt' delimiter ',' csv; I get the following error: ERROR: duplicate key value violates unique constraint "mmcompany_phonenumber_key" I understand why it's happening, but how do I execute the command in a way that valid entries will be inserted and ones that create an error will be discarded? 回答1: The reason PostgreSQL doesn't do this is related to how it implements constraints and validation. When a constraint fails