Cannot add or update a child row: a foreign key constraint fails (ldb
.pet
, CONSTRAINT master_id
FOREIGN KEY (master_id
) REFERENCES master
(id
))
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (ldb
.pet
, CONSTRAINT master_id
FOREIGN KEY (master_id
) REFERENCES master
(id
))
外键异常,外键一般对应另一个表的主键,对外键值更新时,要确保另一个表的主键有存在该值,否则插入报错,违反主键约束