MySQL “ERROR 1005 (HY000): Can't create table 'foo.#sql-12c_4' (errno: 150)”

后端 未结 14 810
情深已故
情深已故 2020-12-03 04:13

I was working on creating some tables in database foo, but every time I end up with errno 150 regarding the foreign key. Firstly, here\'s my code for creating t

14条回答
  •  死守一世寂寞
    2020-12-03 05:08

    Check that BOTH tables have the same ENGINE. For example if you have:

    CREATE Table FOO ();
    

    and:

    CREATE Table BAR () ENGINE=INNODB;
    

    If you try to create a constraint from table BAR to table FOO, it will not work on certain MySQL versions.

    Fix the issue by following:

    CREATE Table FOO () ENGINE=INNODB;
    

提交回复
热议问题