Adding Foreign Key Error

后端 未结 5 1405
盖世英雄少女心
盖世英雄少女心 2021-01-26 07:37

I want to add a foreign key from Table Customers, row= \"Customer ID\" to Table Pet, row= \"Customer ID\".

-- Table struct         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-26 08:00

    The CustomerID you're trying to enter in PETS table, does not exist in CUSTOMERS table, and that is why your Foreign Key constraint fails and throws error.

    You need to ensure that the CustomerIDs you're entering in your Pets table, exist in Customers table OR simply insert NULL in the PETS.CUSTOMERID field

提交回复
热议问题