Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql error 1215

When you are trying to reference a key on parent table which is not a candidate key (either a primary key or a unique key) you may get the error code: 1215 cannot add foreign key constraint. ... It does not necessarily to be a primary key. MySQL requires index on corresponding referenced key, so you need a unique key
 
PREVIOUS NEXT
Tagged: #mysql #error
ADD COMMENT
Topic
Name
8+5 =