Question #5793   Submitted by Answiki on 01/25/2022 at 06:08:44 PM UTC

#1215 - Cannot add foreign key constraint, why this error?

Answer   Submitted by Answiki on 01/25/2022 at 06:10:34 PM UTC

#1215: Cannot add foreign key constraint

The above MySQL error #1215 can occur for one of the several reasons:

  • You are trying to reference a key that does not exist in the external table.
  • The columns are not of the same type (for example, INT to BIGINT, UNSIGNED INT to INT ...). To create a relationship between two tables, the columns concerned must be strictly of the same type.
  • Tables are not of the same type (for example, InnoDB to MyISAM). To create a relationship between two tables, they must be of the same type.
2 events in history
Answer by Answiki on 01/25/2022 at 06:10:34 PM

#1215: Cannot add foreign key constraint

The above MySQL error #1215 can occur for one of the several reasons:

  • You are trying to reference a key that does not exist in the external table.
  • The columns are not of the same type (for example, INT to BIGINT, UNSIGNED INT to INT ...). To create a relationship between two tables, the columns concerned must be strictly of the same type.
  • Tables are not of the same type (for example, InnoDB to MyISAM). To create a relationship between two tables, they must be of the same type.
Question by Answiki 01/25/2022 at 06:08:44 PM
#1215 - Cannot add foreign key constraint, why this error?
# ID Query URL Count

Icons proudly provided by Friconix.