MySQL Forums
Forum List  »  Newbie

Re: CANNOT ADD FOREIGN KEY CONSTRAIN
Posted by: Phillip Ward
Date: December 06, 2021 09:20AM

The Data Types used in Foreign Key relationships must be the same in both Tables:

CREATE TABLE Coffeeshop 
( Shop_id INT UNSIGNED NOT NULL 
, . . . 
, PRIMARY KEY (Shop_id) 
);

CREATE TABLE employee 
( . . . 
, Employee_Shop_Id INT
, . . . 
);

ALTER TABLE Employee 
. . . 
ADD CONSTRAINT checks 
FOREIGN KEY (Employee_Shop_Id) REFERENCES Coffeeshop (Shop_Id)

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: CANNOT ADD FOREIGN KEY CONSTRAIN
December 06, 2021 09:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.