I can't seem to find an answer for my problem, maybe I'm not asking the right question but here it goes:
I have basically two tables in pgAdmin, let's say student
and grades
, eventually with a foreign key constraint (student_id referencing student(id)
CREATE TABLE student (
id CHAR(2),
name CHAR(4),
PRIMARY KEY (id));
CREATE TABLE grade (
student_id CHAR(2),
grade INT,
FOREIGN KEY (student_id) REFERENCES student(id));
What I'd like to do is copy/import two files into the databases. All good for students but my grade.csv
files will contain non-existing student IDs and I want the import to ignore and not insert them. Instead of that, the command fails, nothing is imported.
What would be a correct and efficient way to do this?