0
Hello I am trying to add a foreign key to a table but I get error 1215. I have already checked the attributes and all are compatible, the portfolio field is a primary key, I do not understand why it is not possible to add the key.
ALTER TABLE `acoes_db`.`Carteira`
ADD CONSTRAINT `carteira_fk`
FOREIGN KEY (`ID`)
REFERENCES `acoes_db`.`Acionistas` (`Carteira`)
ON DELETE CASCADE
ON UPDATE CASCADE;