Insert Data Into Postgresql With Duplicate Values
I need to insert dataset in postgresql. INSERT INTO table_subject_topics_exams (name_of_subject, section, topic, subtopic) VALUES ('Algebra', 'Mathematics', 'Progressions', 'Number
Solution 1:
If you don't want duplicates inserted, then add a unique index or constraint:
CREATE UNIQUE INDEX unq_table_subject_topics_exams_3 ON table_subject_topics_exams(name_of_subject, section, topic, subtopic);
If you want your insert to succeed for the non-duplicated values, then add:
ON CONFLICT DONOTHINGas the last line of the INSERT.
Here is a db<>fiddle.
Post a Comment for "Insert Data Into Postgresql With Duplicate Values"