【发布时间】:2020-11-20 23:31:17
【问题描述】:
对于表table1_table2_map这样的语句
INSERT INTO table1_table2_map
(table1_id, table2_id)
VALUES
(-999,-999), -- Both Valid
(3,4), -- Both Bad
(-999, 3) -- One is Bad
上面提到的表有两个外键引用:
`FOREIGN KEY (`table1_id`) REFERENCES `table1_lkp`
` FOREIGN KEY (`table2_id`) REFERENCES `table2_lkp`
插入错误如下:
> Cannot add or update a child row: a foreign key constraint fails (`test_nv2rnuw4yh`.`table1_table2_map`, CONSTRAINT `fk_table1_id` FOREIGN KEY (`table1_id`) REFERENCES `table1_lkp` (`table1_id`)).
如何检测一行引发错误的信息?
【问题讨论】:
-
谢谢,@Progman。我是唯一一个对为什么错误声明没有给出更多细节感到困惑的人吗?
标签: mysql