I am using COPY table_name FROM STDIN to import data. It is very efficient, but if there's any violation of duplicate keys, the whole procedure will be stopped. Is there anyway to around this?
why does not postgresql just give a warning and copy rest of the data?
Here's the example :
select * from "Demo1";
Id | Name | Age
---+-------+-----
1 | abc | 20
2 | def | 22
COPY "Demo1" from STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> 3 pqr 25
>> 4 xyz 26
>> 5 abc 21
>> \.
ERROR: duplicate key value violates unique constraint "Demo1_Name_key"
DETAIL: Key ("Name")=(abc) already exists.
CONTEXT: COPY Demo1, line 3
Here "Name" field is having unique constraint. Since string "abc" is already present in table. Its ignoring whole process.