Adding Foreign Key Error

后端 未结 5 1403
盖世英雄少女心
盖世英雄少女心 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:01

    try this

    CREATE TABLE IF NOT EXISTS `Pet` (
      `ID` varchar(50) NOT NULL,
      FOREIGN KEY (`CustomerID`) REFERENCES Customers(CustomerID) varchar(50) NOT NULL,
      `Gender` varchar(20) DEFAULT NULL,
      `Race` varchar(20) DEFAULT NULL,
      `Name` varchar(20) DEFAULT NULL,
      `Kind` varchar(20) DEFAULT NULL,
      `Birthday` varchar(20) DEFAULT NULL,
       PRIMARY KEY (`ID`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

提交回复
热议问题