INSERT语句与FOREIGN KEY冲突 [英] INSERT statement conflicted with the FOREIGN KEY
本文介绍了INSERT语句与FOREIGN KEY冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有四张桌子
Order_Request
Tbl_Printer
Tbl_Monitor
Tbl_CPU
我有一个关系FK_Tbl_Order_Request_Tbl_CPU和FK_Tbl_Order_Request_Tbl_Monitor
FK_Tbl_Order_Request_Tbl_Printer
当我尝试输入moniter的数据时Order_Request它给我错误
I Have four table
Order_Request
Tbl_Printer
Tbl_Monitor
Tbl_CPU
I have a relation FK_Tbl_Order_Request_Tbl_CPU and FK_Tbl_Order_Request_Tbl_Monitor
FK_Tbl_Order_Request_Tbl_Printer
when i try to enter data for moniter in Order_Request its giving me error
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Tbl_Order_Request_Tbl_CPU". The conflict occurred in database "EHealthInventory1", table "dbo.Tbl_CPU", column 'CPU_ID'.
The statement has been terminated.
推荐答案
错误明确指出与外键约束存在冲突。这意味着您正在尝试插入外键表中不存在的值。在您的情况下,您在表中插入的CPU_ID的值在dbo.Tbl_CPU中不存在。您在表中插入的外键值必须存在于其引用的表中。
The error clearly states that there is a conflict with the foreign key constraint. It means you are trying to insert a value that does not exist in the Foreign Key table. In your case the value of "CPU_ID" you are inserting in the table does not exist in "dbo.Tbl_CPU". The foreign key values you insert in a table must exist in their referenced tables.
这篇关于INSERT语句与FOREIGN KEY冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文