0

I want to delete 2 rows of 2 tables that have mutual constraints. I can't modify the database structure.

The structure is something like this:

A (id, b_id, other_data) FOREIGN KEY (b_id) REFERENCES B(id)
B (id, a_id, other_data) FOREIGN KEY (a_id) REFERENCES A(id)

I thought that if I delete the 2 rows in the same transaction the constraints will be checked at the end, but I am having an error of constraint violation when tries to delete the first one.

Which is the right way to do this?

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Matías González
  • 1,366
  • 3
  • 15
  • 30

0 Answers0