Forum Stats

  • 3,783,394 Users
  • 2,254,768 Discussions


Insertion of Data with foreign key constraint

Any constraint if violated during the bulk insertion, will insert records satisfying the constrants or abort the complete insertion.

Example: I have 100 rows and I wrote an insert statement with select.

insert into table_2(col1, col2, col3) select * from table1;

say suppose col1 having a foreign key constraint, a row smewhere in the middle is not satisfying this constraint, so will my insert query be

1) inserting all other records,

2) or records coming previous to the record having problem,

3) or no records will be inserted