2017-05-08 101 views
0

我有這張表 與essn = int,pno = int,hours = decimal(5,2)與essn和pno是主鍵,當我試圖插入值,這個錯誤occurrssql錯誤:ORA-02291:違反完整性約束(MHVU.WORKS_ON_FK) - 父鍵未找到

enter image description here

+0

請閱讀http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557和接受的答案 –

+1

不相關,但是:在SQL中指定的數字**沒有**單引號。 ''1'是字符串常量。 '1'是一個數字 –

回答

0

ORA-02291:違反完整性約束(string.string) - 沒有找到父鍵

原因:外鍵值沒有匹配的主鍵值。

操作:刪除外鍵或添加匹配的主鍵。

對於插入語句,當您嘗試插入沒有匹配父項的子項時(如外鍵約束定義的),此ORA-02291錯誤很常見。在這種情況下,您需要將父行添加到表中,然後重新插入您的子錶行。

相關問題