I'm finding it very difficult to create a foreign key
between two tables, whose type is varchar
:
ALTER TABLE netmap ADD CONSTRAINT fk_IP FOREIGN KEY ( IP ) REFERENCES ipvalidos (IPS);
The error is:
Failed to execute SQL: SQL ALTER TABLE netmap ADD CONSTRAINT fk_IP FOREIGN KEY (IP) REFERENCES ipvalidos (IPS) failed: Can not add foreign key constraint
Before trying to foreign key
, I gave describe
, which looks like this:
ipvalidos
Field Type Null Key Default Extra
IPS varchar(255) NO PRI
netmap
Field Type Null Key Default Extra
IP varchar(15) NO MUL
MAC varchar(17) NO PRI
MASK varchar(15) NO
NETID varchar(15) NO MUL
I need to make a comparison between these tables, but I do not know where to start.