MySQL: Can't create table (errno: 150)

后端 未结 30 3031
误落风尘
误落风尘 2020-11-22 06:48

I am trying to import a .sql file and its failing on creating tables.

Here\'s the query that fails:

CREATE TABLE `data` (
`id` int(10) unsigned NOT NUL         


        
30条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 07:11

    After cruising through the answers above, and experimenting a bit, this is an effective way to solve Foreign Key errors in MySQL (1005 - error 150).

    For the foreign key to be properly created, all MySQL asks for is:

    • All referenced keys MUST have either PRIMARY or UNIQUE index.
    • Referencing Column again MUST have identical data type to the Referenced column.

    Satisfy these requirements and all will be well.

提交回复
热议问题