Sql updating tables with foreign keys
It means that you can only insert a row into the child table if there is a corresponding row in the parent table.
To enforce this logic, we place a foreign key on the ORDERS table and have it reference the primary key of the CUSTOMER table.
If you want to avoid losing rows where you can't find a matching row in .
In addition to what I already listed under the prequel question: If the INSERT is huge and constitutes a large proportion of the target table, it is probably faster to DROP all indexes on the target table and recreate them afterwards.
Foreign Key A foreign key is a column (or columns) that references a column (most often the primary key) of another table.
The purpose of the foreign key is to ensure referential integrity of the data.