I have two tables one call _hardware_
and another call _responsavel_
. In _responsavel_
I have a Primary Key
called NIP
of type VARCHAR(8)
. I created a field called NIP_RESP
also VARCHAR(8)
, I'd like to reference the NIP
column of the _responsavel_
table as Foreign Key
in the NIP_RESP
column of the _hardware
table.
Code
ALTER TABLE hardware
ADD CONSTRAINT 'fk_NIP_RESP' FOREIGN KEY ( NIP_RESP ) REFERENCES responsavel ( NIP );
Error
failed: Can not add foreign key constraint
It should be noted that both are NOT NULL DEFAULT VALUE 99999999