If I am manually inserting hundreds of rows, how should I efficiently write the insert statements so that each insert will not run only if both foreign keys are already present together in a record in that database?
How to prevent inserting duplicate rows based on two foreign keys?
1.6k views Asked by Orin At
2
Create a
constraint
on the columns, here is a great reference starting point.Here is an example of a
FOREIGN KEY
constraint, and for defining aFOREIGN KEY
constraint on multiple columns, use the following SQL syntax: