0
I have two tables a call _hardware_
and another call _responsavel_
. In the _responsavel_
have a Primary Key
calling for NIP
of the kind VARCHAR(8)
. I created a field called NIP_RESP
also VARCHAR(8)
, would like to reference the column NIP
table _responsavel_
as Foreign Key
in the column NIP_RESP
table _hardware
.
Code
ALTER TABLE hardware
ADD CONSTRAINT `fk_NIP_RESP` FOREIGN KEY ( NIP_RESP ) REFERENCES responsavel ( NIP );
Error
failed : Cannot add Foreign key Constraint
It should be noted that both are NOT NULL DEFAULT VALUE 99999999
some of the fields are different in some aspect, the best way to see is to give a SHOW ENGINE INNODB STATUS; and see the last Foreign key related error after your attempt
– Lucas Miranda
Ehp possible you reactor
– It Wasn't Me